diff options
author | Jens Arnold <amiconn@rockbox.org> | 2009-06-07 21:27:05 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2009-06-07 21:27:05 +0000 |
commit | 1d6df54df27cb41c02226678a2c8f9feddd1a1e0 (patch) | |
tree | 5fdc6dd98ac0208f5c3351b062063af6914cbefb /firmware | |
parent | c3182ec333982e961d3babfbdb1125fd5bac7fb8 (diff) | |
download | rockbox-1d6df54df27cb41c02226678a2c8f9feddd1a1e0.tar.gz rockbox-1d6df54df27cb41c02226678a2c8f9feddd1a1e0.zip |
Convert a number of places in core and plugins to use the BIT_N() macro instead of 1<<n. Speeds up things on SH1, and also reduces core binsize. Most notable speedups: 1 bit lcd driver: drawpixel +20%, drawline + 27%, hline +5%; jpeg viewer: +8% for 1/8 scaling. Other targets are unaffected.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21205 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/ata.c | 6 | ||||
-rw-r--r-- | firmware/drivers/ata_mmc.c | 2 | ||||
-rw-r--r-- | firmware/drivers/lcd-1bit-vert.c | 8 | ||||
-rw-r--r-- | firmware/screendump.c | 4 |
4 files changed, 10 insertions, 10 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index 88633f0ec9..adc720eaf8 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c | |||
@@ -1268,7 +1268,7 @@ static int set_multiple_mode(int sectors) | |||
1268 | #ifdef HAVE_ATA_DMA | 1268 | #ifdef HAVE_ATA_DMA |
1269 | static int get_best_mode(unsigned short identword, int max, int modetype) | 1269 | static int get_best_mode(unsigned short identword, int max, int modetype) |
1270 | { | 1270 | { |
1271 | unsigned short testbit = 1u << max; | 1271 | unsigned short testbit = BIT_N(max); |
1272 | 1272 | ||
1273 | while (1) { | 1273 | while (1) { |
1274 | if (identword & testbit) | 1274 | if (identword & testbit) |
@@ -1335,7 +1335,7 @@ static int set_features(void) | |||
1335 | } | 1335 | } |
1336 | 1336 | ||
1337 | for (i=0; i < (int)(sizeof(features)/sizeof(features[0])); i++) { | 1337 | for (i=0; i < (int)(sizeof(features)/sizeof(features[0])); i++) { |
1338 | if (identify_info[features[i].id_word] & (1u << features[i].id_bit)) { | 1338 | if (identify_info[features[i].id_word] & BIT_N(features[i].id_bit)) { |
1339 | SET_REG(ATA_FEATURE, features[i].subcommand); | 1339 | SET_REG(ATA_FEATURE, features[i].subcommand); |
1340 | SET_REG(ATA_NSECTOR, features[i].parameter); | 1340 | SET_REG(ATA_NSECTOR, features[i].parameter); |
1341 | SET_REG(ATA_COMMAND, CMD_SET_FEATURES); | 1341 | SET_REG(ATA_COMMAND, CMD_SET_FEATURES); |
@@ -1461,7 +1461,7 @@ int ata_init(void) | |||
1461 | #ifdef MAX_PHYS_SECTOR_SIZE | 1461 | #ifdef MAX_PHYS_SECTOR_SIZE |
1462 | /* Find out the physical sector size */ | 1462 | /* Find out the physical sector size */ |
1463 | if((identify_info[106] & 0xe000) == 0x6000) | 1463 | if((identify_info[106] & 0xe000) == 0x6000) |
1464 | phys_sector_mult = 1 << (identify_info[106] & 0x000f); | 1464 | phys_sector_mult = BIT_N(identify_info[106] & 0x000f); |
1465 | else | 1465 | else |
1466 | phys_sector_mult = 1; | 1466 | phys_sector_mult = 1; |
1467 | 1467 | ||
diff --git a/firmware/drivers/ata_mmc.c b/firmware/drivers/ata_mmc.c index 5104f8cf97..3396149602 100644 --- a/firmware/drivers/ata_mmc.c +++ b/firmware/drivers/ata_mmc.c | |||
@@ -450,7 +450,7 @@ static int initialize_card(int card_no) | |||
450 | card->tsac = card->tsac * exponent[taac_exp] / 10; | 450 | card->tsac = card->tsac * exponent[taac_exp] / 10; |
451 | 451 | ||
452 | /* r2w_factor, write timeout */ | 452 | /* r2w_factor, write timeout */ |
453 | card->r2w_factor = 1 << card_extract_bits(card->csd, 99, 3); | 453 | card->r2w_factor = BIT_N(card_extract_bits(card->csd, 99, 3)); |
454 | card->write_timeout = card->read_timeout * card->r2w_factor; | 454 | card->write_timeout = card->read_timeout * card->r2w_factor; |
455 | 455 | ||
456 | if (card->r2w_factor > 32) /* Such cards often need extra read delay */ | 456 | if (card->r2w_factor > 32) /* Such cards often need extra read delay */ |
diff --git a/firmware/drivers/lcd-1bit-vert.c b/firmware/drivers/lcd-1bit-vert.c index b09ce0e76d..5fb652431c 100644 --- a/firmware/drivers/lcd-1bit-vert.c +++ b/firmware/drivers/lcd-1bit-vert.c | |||
@@ -155,17 +155,17 @@ int LCDFN(getstringsize)(const unsigned char *str, int *w, int *h) | |||
155 | 155 | ||
156 | static void setpixel(int x, int y) | 156 | static void setpixel(int x, int y) |
157 | { | 157 | { |
158 | LCDFN(framebuffer)[y>>3][x] |= 1 << (y & 7); | 158 | LCDFN(framebuffer)[y>>3][x] |= BIT_N(y & 7); |
159 | } | 159 | } |
160 | 160 | ||
161 | static void clearpixel(int x, int y) | 161 | static void clearpixel(int x, int y) |
162 | { | 162 | { |
163 | LCDFN(framebuffer)[y>>3][x] &= ~(1 << (y & 7)); | 163 | LCDFN(framebuffer)[y>>3][x] &= ~BIT_N(y & 7); |
164 | } | 164 | } |
165 | 165 | ||
166 | static void flippixel(int x, int y) | 166 | static void flippixel(int x, int y) |
167 | { | 167 | { |
168 | LCDFN(framebuffer)[y>>3][x] ^= 1 << (y & 7); | 168 | LCDFN(framebuffer)[y>>3][x] ^= BIT_N(y & 7); |
169 | } | 169 | } |
170 | 170 | ||
171 | static void nopixel(int x, int y) | 171 | static void nopixel(int x, int y) |
@@ -401,7 +401,7 @@ void LCDFN(hline)(int x1, int x2, int y) | |||
401 | 401 | ||
402 | bfunc = LCDFN(blockfuncs)[current_vp->drawmode]; | 402 | bfunc = LCDFN(blockfuncs)[current_vp->drawmode]; |
403 | dst = &LCDFN(framebuffer)[y>>3][x1]; | 403 | dst = &LCDFN(framebuffer)[y>>3][x1]; |
404 | mask = 1 << (y & 7); | 404 | mask = BIT_N(y & 7); |
405 | 405 | ||
406 | dst_end = dst + width; | 406 | dst_end = dst + width; |
407 | do | 407 | do |
diff --git a/firmware/screendump.c b/firmware/screendump.c index 3a3985505e..e84afb9511 100644 --- a/firmware/screendump.c +++ b/firmware/screendump.c | |||
@@ -169,7 +169,7 @@ void screen_dump(void) | |||
169 | #if LCD_DEPTH == 1 | 169 | #if LCD_DEPTH == 1 |
170 | dst_end = dst + LCD_WIDTH/2; | 170 | dst_end = dst + LCD_WIDTH/2; |
171 | src = lcd_framebuffer[y >> 3]; | 171 | src = lcd_framebuffer[y >> 3]; |
172 | mask = 1 << (y & 7); | 172 | mask = BIT_N(y & 7); |
173 | 173 | ||
174 | do | 174 | do |
175 | { | 175 | { |
@@ -333,7 +333,7 @@ void remote_screen_dump(void) | |||
333 | #if LCD_REMOTE_DEPTH == 1 | 333 | #if LCD_REMOTE_DEPTH == 1 |
334 | dst_end = dst + LCD_REMOTE_WIDTH/2; | 334 | dst_end = dst + LCD_REMOTE_WIDTH/2; |
335 | src = lcd_remote_framebuffer[y >> 3]; | 335 | src = lcd_remote_framebuffer[y >> 3]; |
336 | mask = 1 << (y & 7); | 336 | mask = BIT_N(y & 7); |
337 | 337 | ||
338 | do | 338 | do |
339 | { | 339 | { |