aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends
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
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')
-rw-r--r--drivers/media/dvb/frontends/af9013.c37
-rw-r--r--drivers/media/dvb/frontends/af9013_priv.h69
2 files changed, 44 insertions, 62 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 }
diff --git a/drivers/media/dvb/frontends/af9013_priv.h b/drivers/media/dvb/frontends/af9013_priv.h
index fc9a32d9e632..e00b2a4a2db6 100644
--- a/drivers/media/dvb/frontends/af9013_priv.h
+++ b/drivers/media/dvb/frontends/af9013_priv.h
@@ -63,44 +63,51 @@ struct snr_table {
63struct coeff { 63struct coeff {
64 u32 adc_clock; 64 u32 adc_clock;
65 fe_bandwidth_t bw; 65 fe_bandwidth_t bw;
66 u32 ns_coeff1_2048nu; 66 u8 val[24];
67 u32 ns_coeff1_8191nu;
68 u32 ns_coeff1_8192nu;
69 u32 ns_coeff1_8193nu;
70 u32 ns_coeff2_2k;
71 u32 ns_coeff2_8k;
72}; 67};
73 68
74/* coeff lookup table */ 69/* pre-calculated coeff lookup table */
75static struct coeff coeff_table[] = { 70static struct coeff coeff_table[] = {
76 /* 28.800 MHz */ 71 /* 28.800 MHz */
77 { 28800, BANDWIDTH_6_MHZ, 0x01e79e7a, 0x0079eb6e, 0x0079e79e, 72 { 28800, BANDWIDTH_8_MHZ, { 0x02, 0x8a, 0x28, 0xa3, 0x05, 0x14,
78 0x0079e3cf, 0x00f3cf3d, 0x003cf3cf }, 73 0x51, 0x11, 0x00, 0xa2, 0x8f, 0x3d, 0x00, 0xa2, 0x8a,
79 { 28800, BANDWIDTH_7_MHZ, 0x0238e38e, 0x008e3d55, 0x008e38e4, 74 0x29, 0x00, 0xa2, 0x85, 0x14, 0x01, 0x45, 0x14, 0x14 } },
80 0x008e3472, 0x011c71c7, 0x00471c72 }, 75 { 28800, BANDWIDTH_7_MHZ, { 0x02, 0x38, 0xe3, 0x8e, 0x04, 0x71,
81 { 28800, BANDWIDTH_8_MHZ, 0x028a28a3, 0x00a28f3d, 0x00a28a29, 76 0xc7, 0x07, 0x00, 0x8e, 0x3d, 0x55, 0x00, 0x8e, 0x38,
82 0x00a28514, 0x01451451, 0x00514514 }, 77 0xe4, 0x00, 0x8e, 0x34, 0x72, 0x01, 0x1c, 0x71, 0x32 } },
78 { 28800, BANDWIDTH_6_MHZ, { 0x01, 0xe7, 0x9e, 0x7a, 0x03, 0xcf,
79 0x3c, 0x3d, 0x00, 0x79, 0xeb, 0x6e, 0x00, 0x79, 0xe7,
80 0x9e, 0x00, 0x79, 0xe3, 0xcf, 0x00, 0xf3, 0xcf, 0x0f } },
83 /* 20.480 MHz */ 81 /* 20.480 MHz */
84 { 20480, BANDWIDTH_6_MHZ, 0x02adb6dc, 0x00ab7313, 0x00ab6db7, 82 { 20480, BANDWIDTH_8_MHZ, { 0x03, 0x92, 0x49, 0x26, 0x07, 0x24,
85 0x00ab685c, 0x0156db6e, 0x0055b6dc }, 83 0x92, 0x13, 0x00, 0xe4, 0x99, 0x6e, 0x00, 0xe4, 0x92,
86 { 20480, BANDWIDTH_7_MHZ, 0x03200001, 0x00c80640, 0x00c80000, 84 0x49, 0x00, 0xe4, 0x8b, 0x25, 0x01, 0xc9, 0x24, 0x25 } },
87 0x00c7f9c0, 0x01900000, 0x00640000 }, 85 { 20480, BANDWIDTH_7_MHZ, { 0x03, 0x20, 0x00, 0x01, 0x06, 0x40,
88 { 20480, BANDWIDTH_8_MHZ, 0x03924926, 0x00e4996e, 0x00e49249, 86 0x00, 0x00, 0x00, 0xc8, 0x06, 0x40, 0x00, 0xc8, 0x00,
89 0x00e48b25, 0x01c92493, 0x00724925 }, 87 0x00, 0x00, 0xc7, 0xf9, 0xc0, 0x01, 0x90, 0x00, 0x00 } },
88 { 20480, BANDWIDTH_6_MHZ, { 0x02, 0xad, 0xb6, 0xdc, 0x05, 0x5b,
89 0x6d, 0x2e, 0x00, 0xab, 0x73, 0x13, 0x00, 0xab, 0x6d,
90 0xb7, 0x00, 0xab, 0x68, 0x5c, 0x01, 0x56, 0xdb, 0x1c } },
90 /* 28.000 MHz */ 91 /* 28.000 MHz */
91 { 28000, BANDWIDTH_6_MHZ, 0x01f58d10, 0x007d672f, 0x007d6344, 92 { 28000, BANDWIDTH_8_MHZ, { 0x02, 0x9c, 0xbc, 0x15, 0x05, 0x39,
92 0x007d5f59, 0x00fac688, 0x003eb1a2 }, 93 0x78, 0x0a, 0x00, 0xa7, 0x34, 0x3f, 0x00, 0xa7, 0x2f,
93 { 28000, BANDWIDTH_7_MHZ, 0x02492492, 0x00924db7, 0x00924925, 94 0x05, 0x00, 0xa7, 0x29, 0xcc, 0x01, 0x4e, 0x5e, 0x03 } },
94 0x00924492, 0x01249249, 0x00492492 }, 95 { 28000, BANDWIDTH_7_MHZ, { 0x02, 0x49, 0x24, 0x92, 0x04, 0x92,
95 { 28000, BANDWIDTH_8_MHZ, 0x029cbc15, 0x00a7343f, 0x00a72f05, 96 0x49, 0x09, 0x00, 0x92, 0x4d, 0xb7, 0x00, 0x92, 0x49,
96 0x00a729cc, 0x014e5e0a, 0x00539783 }, 97 0x25, 0x00, 0x92, 0x44, 0x92, 0x01, 0x24, 0x92, 0x12 } },
98 { 28000, BANDWIDTH_6_MHZ, { 0x01, 0xf5, 0x8d, 0x10, 0x03, 0xeb,
99 0x1a, 0x08, 0x00, 0x7d, 0x67, 0x2f, 0x00, 0x7d, 0x63,
100 0x44, 0x00, 0x7d, 0x5f, 0x59, 0x00, 0xfa, 0xc6, 0x22 } },
97 /* 25.000 MHz */ 101 /* 25.000 MHz */
98 { 25000, BANDWIDTH_6_MHZ, 0x0231bcb5, 0x008c7391, 0x008c6f2d, 102 { 25000, BANDWIDTH_8_MHZ, { 0x02, 0xec, 0xfb, 0x9d, 0x05, 0xd9,
99 0x008c6aca, 0x0118de5b, 0x00463797 }, 103 0xf7, 0x0e, 0x00, 0xbb, 0x44, 0xc1, 0x00, 0xbb, 0x3e,
100 { 25000, BANDWIDTH_7_MHZ, 0x028f5c29, 0x00a3dc29, 0x00a3d70a, 104 0xe7, 0x00, 0xbb, 0x39, 0x0d, 0x01, 0x76, 0x7d, 0x34 } },
101 0x00a3d1ec, 0x0147ae14, 0x0051eb85 }, 105 { 25000, BANDWIDTH_7_MHZ, { 0x02, 0x8f, 0x5c, 0x29, 0x05, 0x1e,
102 { 25000, BANDWIDTH_8_MHZ, 0x02ecfb9d, 0x00bb44c1, 0x00bb3ee7, 106 0xb8, 0x14, 0x00, 0xa3, 0xdc, 0x29, 0x00, 0xa3, 0xd7,
103 0x00bb390d, 0x01767dce, 0x005d9f74 }, 107 0x0a, 0x00, 0xa3, 0xd1, 0xec, 0x01, 0x47, 0xae, 0x05 } },
108 { 25000, BANDWIDTH_6_MHZ, { 0x02, 0x31, 0xbc, 0xb5, 0x04, 0x63,
109 0x79, 0x1b, 0x00, 0x8c, 0x73, 0x91, 0x00, 0x8c, 0x6f,
110 0x2d, 0x00, 0x8c, 0x6a, 0xca, 0x01, 0x18, 0xde, 0x17 } },
104}; 111};
105 112
106/* QPSK SNR lookup table */ 113/* QPSK SNR lookup table */