aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends/af9013.c
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2010-10-06 20:35:20 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-10-20 23:17:54 -0400
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)
220 220
221static int af9013_set_coeff(struct af9013_state *state, fe_bandwidth_t bw) 221static int af9013_set_coeff(struct af9013_state *state, fe_bandwidth_t bw)
222{ 222{
223 int ret, i, found; 223 int ret, i, j, found;
224 u8 buf[24];
225 deb_info("%s: adc_clock:%d bw:%d\n", __func__, 224 deb_info("%s: adc_clock:%d bw:%d\n", __func__,
226 state->config.adc_clock, bw); 225 state->config.adc_clock, bw);
227 226
@@ -240,37 +239,13 @@ static int af9013_set_coeff(struct af9013_state *state, fe_bandwidth_t bw)
240 goto error; 239 goto error;
241 } 240 }
242 241
243 buf[0] = (u8) ((coeff_table[i].ns_coeff1_2048nu & 0x03000000) >> 24); 242 deb_info("%s: coeff: ", __func__);
244 buf[1] = (u8) ((coeff_table[i].ns_coeff1_2048nu & 0x00ff0000) >> 16); 243 debug_dump(coeff_table[i].val, sizeof(coeff_table[i].val), deb_info);
245 buf[2] = (u8) ((coeff_table[i].ns_coeff1_2048nu & 0x0000ff00) >> 8);
246 buf[3] = (u8) ((coeff_table[i].ns_coeff1_2048nu & 0x000000ff));
247 buf[4] = (u8) ((coeff_table[i].ns_coeff2_2k & 0x01c00000) >> 22);
248 buf[5] = (u8) ((coeff_table[i].ns_coeff2_2k & 0x003fc000) >> 14);
249 buf[6] = (u8) ((coeff_table[i].ns_coeff2_2k & 0x00003fc0) >> 6);
250 buf[7] = (u8) ((coeff_table[i].ns_coeff2_2k & 0x0000003f));
251 buf[8] = (u8) ((coeff_table[i].ns_coeff1_8191nu & 0x03000000) >> 24);
252 buf[9] = (u8) ((coeff_table[i].ns_coeff1_8191nu & 0x00ffc000) >> 16);
253 buf[10] = (u8) ((coeff_table[i].ns_coeff1_8191nu & 0x0000ff00) >> 8);
254 buf[11] = (u8) ((coeff_table[i].ns_coeff1_8191nu & 0x000000ff));
255 buf[12] = (u8) ((coeff_table[i].ns_coeff1_8192nu & 0x03000000) >> 24);
256 buf[13] = (u8) ((coeff_table[i].ns_coeff1_8192nu & 0x00ffc000) >> 16);
257 buf[14] = (u8) ((coeff_table[i].ns_coeff1_8192nu & 0x0000ff00) >> 8);
258 buf[15] = (u8) ((coeff_table[i].ns_coeff1_8192nu & 0x000000ff));
259 buf[16] = (u8) ((coeff_table[i].ns_coeff1_8193nu & 0x03000000) >> 24);
260 buf[17] = (u8) ((coeff_table[i].ns_coeff1_8193nu & 0x00ffc000) >> 16);
261 buf[18] = (u8) ((coeff_table[i].ns_coeff1_8193nu & 0x0000ff00) >> 8);
262 buf[19] = (u8) ((coeff_table[i].ns_coeff1_8193nu & 0x000000ff));
263 buf[20] = (u8) ((coeff_table[i].ns_coeff2_8k & 0x01c00000) >> 22);
264 buf[21] = (u8) ((coeff_table[i].ns_coeff2_8k & 0x003fc000) >> 14);
265 buf[22] = (u8) ((coeff_table[i].ns_coeff2_8k & 0x00003fc0) >> 6);
266 buf[23] = (u8) ((coeff_table[i].ns_coeff2_8k & 0x0000003f));
267
268 deb_info("%s: coeff:", __func__);
269 debug_dump(buf, sizeof(buf), deb_info);
270 244
271 /* program */ 245 /* program */
272 for (i = 0; i < sizeof(buf); i++) { 246 for (j = 0; j < sizeof(coeff_table[i].val); j++) {
273 ret = af9013_write_reg(state, 0xae00 + i, buf[i]); 247 ret = af9013_write_reg(state, 0xae00 + j,
248 coeff_table[i].val[j]);
274 if (ret) 249 if (ret)
275 break; 250 break;
276 } 251 }