summaryrefslogtreecommitdiff
path: root/drivers/media/dvb/frontends/af9013.c
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2010-10-06 21:35:20 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-10-21 01:17:54 -0200
commitedb709b61abd3ba475e59d1ad81aab21ad025db6 (patch)
tree1ba6e323683ea9b6a01e34f2bbcafafecfb684d1 /drivers/media/dvb/frontends/af9013.c
parent589851d5990f85cce884f831ec70b9aa40b7ad5f (diff)
[media] af9013: optimize code size
Precalculate coefficients register values. This reduces text size around 300 bytes. Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/frontends/af9013.c')
-rw-r--r--drivers/media/dvb/frontends/af9013.c37
1 files changed, 6 insertions, 31 deletions
diff --git a/drivers/media/dvb/frontends/af9013.c b/drivers/media/dvb/frontends/af9013.c
index 25c5124bfc59..6a205e68fde7 100644
--- a/drivers/media/dvb/frontends/af9013.c
+++ b/drivers/media/dvb/frontends/af9013.c
@@ -220,8 +220,7 @@ static u32 af913_div(u32 a, u32 b, u32 x)
static int af9013_set_coeff(struct af9013_state *state, fe_bandwidth_t bw)
{
- int ret, i, found;
- u8 buf[24];
+ int ret, i, j, found;
deb_info("%s: adc_clock:%d bw:%d\n", __func__,
state->config.adc_clock, bw);
@@ -240,37 +239,13 @@ static int af9013_set_coeff(struct af9013_state *state, fe_bandwidth_t bw)
goto error;
}
- buf[0] = (u8) ((coeff_table[i].ns_coeff1_2048nu & 0x03000000) >> 24);
- buf[1] = (u8) ((coeff_table[i].ns_coeff1_2048nu & 0x00ff0000) >> 16);
- buf[2] = (u8) ((coeff_table[i].ns_coeff1_2048nu & 0x0000ff00) >> 8);
- buf[3] = (u8) ((coeff_table[i].ns_coeff1_2048nu & 0x000000ff));
- buf[4] = (u8) ((coeff_table[i].ns_coeff2_2k & 0x01c00000) >> 22);
- buf[5] = (u8) ((coeff_table[i].ns_coeff2_2k & 0x003fc000) >> 14);
- buf[6] = (u8) ((coeff_table[i].ns_coeff2_2k & 0x00003fc0) >> 6);
- buf[7] = (u8) ((coeff_table[i].ns_coeff2_2k & 0x0000003f));
- buf[8] = (u8) ((coeff_table[i].ns_coeff1_8191nu & 0x03000000) >> 24);
- buf[9] = (u8) ((coeff_table[i].ns_coeff1_8191nu & 0x00ffc000) >> 16);
- buf[10] = (u8) ((coeff_table[i].ns_coeff1_8191nu & 0x0000ff00) >> 8);
- buf[11] = (u8) ((coeff_table[i].ns_coeff1_8191nu & 0x000000ff));
- buf[12] = (u8) ((coeff_table[i].ns_coeff1_8192nu & 0x03000000) >> 24);
- buf[13] = (u8) ((coeff_table[i].ns_coeff1_8192nu & 0x00ffc000) >> 16);
- buf[14] = (u8) ((coeff_table[i].ns_coeff1_8192nu & 0x0000ff00) >> 8);
- buf[15] = (u8) ((coeff_table[i].ns_coeff1_8192nu & 0x000000ff));
- buf[16] = (u8) ((coeff_table[i].ns_coeff1_8193nu & 0x03000000) >> 24);
- buf[17] = (u8) ((coeff_table[i].ns_coeff1_8193nu & 0x00ffc000) >> 16);
- buf[18] = (u8) ((coeff_table[i].ns_coeff1_8193nu & 0x0000ff00) >> 8);
- buf[19] = (u8) ((coeff_table[i].ns_coeff1_8193nu & 0x000000ff));
- buf[20] = (u8) ((coeff_table[i].ns_coeff2_8k & 0x01c00000) >> 22);
- buf[21] = (u8) ((coeff_table[i].ns_coeff2_8k & 0x003fc000) >> 14);
- buf[22] = (u8) ((coeff_table[i].ns_coeff2_8k & 0x00003fc0) >> 6);
- buf[23] = (u8) ((coeff_table[i].ns_coeff2_8k & 0x0000003f));
-
- deb_info("%s: coeff:", __func__);
- debug_dump(buf, sizeof(buf), deb_info);
+ deb_info("%s: coeff: ", __func__);
+ debug_dump(coeff_table[i].val, sizeof(coeff_table[i].val), deb_info);
/* program */
- for (i = 0; i < sizeof(buf); i++) {
- ret = af9013_write_reg(state, 0xae00 + i, buf[i]);
+ for (j = 0; j < sizeof(coeff_table[i].val); j++) {
+ ret = af9013_write_reg(state, 0xae00 + j,
+ coeff_table[i].val[j]);
if (ret)
break;
}