aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2013-02-26 18:57:01 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-03-21 17:57:54 -0400
commit42432b3ce89eaf817284f0c6ff81dfd7b4ed35b3 (patch)
tree0e133a271a6310c341c1cc200aa38995e322f01b
parent8c1285a28084b5fa07a7842dd72a561f5c3b913e (diff)
[media] it913x: rename functions and variables
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/tuners/it913x.c72
1 files changed, 38 insertions, 34 deletions
diff --git a/drivers/media/tuners/it913x.c b/drivers/media/tuners/it913x.c
index 6eb3afa32db6..82cc053bc998 100644
--- a/drivers/media/tuners/it913x.c
+++ b/drivers/media/tuners/it913x.c
@@ -22,7 +22,7 @@
22 22
23#include "it913x_priv.h" 23#include "it913x_priv.h"
24 24
25struct it913x_fe_state { 25struct it913x_state {
26 struct dvb_frontend frontend; 26 struct dvb_frontend frontend;
27 struct i2c_adapter *i2c_adap; 27 struct i2c_adapter *i2c_adap;
28 struct ite_config *config; 28 struct ite_config *config;
@@ -43,7 +43,8 @@ struct it913x_fe_state {
43 u32 ucblocks; 43 u32 ucblocks;
44}; 44};
45 45
46static int it913x_read_reg(struct it913x_fe_state *state, 46/* read multiple registers */
47static int it913x_rd_regs(struct it913x_state *state,
47 u32 reg, u8 *data, u8 count) 48 u32 reg, u8 *data, u8 count)
48{ 49{
49 int ret; 50 int ret;
@@ -64,15 +65,17 @@ static int it913x_read_reg(struct it913x_fe_state *state,
64 return ret; 65 return ret;
65} 66}
66 67
67static int it913x_read_reg_u8(struct it913x_fe_state *state, u32 reg) 68/* read single register */
69static int it913x_rd_reg(struct it913x_state *state, u32 reg)
68{ 70{
69 int ret; 71 int ret;
70 u8 b[1]; 72 u8 b[1];
71 ret = it913x_read_reg(state, reg, &b[0], sizeof(b)); 73 ret = it913x_rd_regs(state, reg, &b[0], sizeof(b));
72 return (ret < 0) ? -ENODEV : b[0]; 74 return (ret < 0) ? -ENODEV : b[0];
73} 75}
74 76
75static int it913x_write(struct it913x_fe_state *state, 77/* write multiple registers */
78static int it913x_wr_regs(struct it913x_state *state,
76 u8 pro, u32 reg, u8 buf[], u8 count) 79 u8 pro, u32 reg, u8 buf[], u8 count)
77{ 80{
78 u8 b[256]; 81 u8 b[256];
@@ -97,7 +100,8 @@ static int it913x_write(struct it913x_fe_state *state,
97 return 0; 100 return 0;
98} 101}
99 102
100static int it913x_write_reg(struct it913x_fe_state *state, 103/* write single register */
104static int it913x_wr_reg(struct it913x_state *state,
101 u8 pro, u32 reg, u32 data) 105 u8 pro, u32 reg, u32 data)
102{ 106{
103 int ret; 107 int ret;
@@ -118,12 +122,12 @@ static int it913x_write_reg(struct it913x_fe_state *state,
118 else 122 else
119 s = 0; 123 s = 0;
120 124
121 ret = it913x_write(state, pro, reg, &b[s], sizeof(b) - s); 125 ret = it913x_wr_regs(state, pro, reg, &b[s], sizeof(b) - s);
122 126
123 return ret; 127 return ret;
124} 128}
125 129
126static int it913x_fe_script_loader(struct it913x_fe_state *state, 130static int it913x_script_loader(struct it913x_state *state,
127 struct it913xset *loadscript) 131 struct it913xset *loadscript)
128{ 132{
129 int ret, i; 133 int ret, i;
@@ -133,7 +137,7 @@ static int it913x_fe_script_loader(struct it913x_fe_state *state,
133 for (i = 0; i < 1000; ++i) { 137 for (i = 0; i < 1000; ++i) {
134 if (loadscript[i].pro == 0xff) 138 if (loadscript[i].pro == 0xff)
135 break; 139 break;
136 ret = it913x_write(state, loadscript[i].pro, 140 ret = it913x_wr_regs(state, loadscript[i].pro,
137 loadscript[i].address, 141 loadscript[i].address,
138 loadscript[i].reg, loadscript[i].count); 142 loadscript[i].reg, loadscript[i].count);
139 if (ret < 0) 143 if (ret < 0)
@@ -142,9 +146,9 @@ static int it913x_fe_script_loader(struct it913x_fe_state *state,
142 return 0; 146 return 0;
143} 147}
144 148
145static int it913x_init_tuner(struct dvb_frontend *fe) 149static int it913x_init(struct dvb_frontend *fe)
146{ 150{
147 struct it913x_fe_state *state = fe->tuner_priv; 151 struct it913x_state *state = fe->tuner_priv;
148 int ret, i, reg; 152 int ret, i, reg;
149 struct it913xset *set_lna; 153 struct it913xset *set_lna;
150 u8 val, nv_val; 154 u8 val, nv_val;
@@ -153,9 +157,9 @@ static int it913x_init_tuner(struct dvb_frontend *fe)
153 157
154 /* v1 or v2 tuner script */ 158 /* v1 or v2 tuner script */
155 if (state->config->chip_ver > 1) 159 if (state->config->chip_ver > 1)
156 ret = it913x_fe_script_loader(state, it9135_v2); 160 ret = it913x_script_loader(state, it9135_v2);
157 else 161 else
158 ret = it913x_fe_script_loader(state, it9135_v1); 162 ret = it913x_script_loader(state, it9135_v1);
159 if (ret < 0) 163 if (ret < 0)
160 return ret; 164 return ret;
161 165
@@ -182,19 +186,19 @@ static int it913x_init_tuner(struct dvb_frontend *fe)
182 } 186 }
183 pr_info("Tuner LNA type :%02x\n", state->tuner_type); 187 pr_info("Tuner LNA type :%02x\n", state->tuner_type);
184 188
185 ret = it913x_fe_script_loader(state, set_lna); 189 ret = it913x_script_loader(state, set_lna);
186 if (ret < 0) 190 if (ret < 0)
187 return ret; 191 return ret;
188 192
189 if (state->config->chip_ver == 2) { 193 if (state->config->chip_ver == 2) {
190 ret = it913x_write_reg(state, PRO_DMOD, TRIGGER_OFSM, 0x1); 194 ret = it913x_wr_reg(state, PRO_DMOD, TRIGGER_OFSM, 0x1);
191 ret |= it913x_write_reg(state, PRO_LINK, PADODPU, 0x0); 195 ret |= it913x_wr_reg(state, PRO_LINK, PADODPU, 0x0);
192 ret |= it913x_write_reg(state, PRO_LINK, AGC_O_D, 0x0); 196 ret |= it913x_wr_reg(state, PRO_LINK, AGC_O_D, 0x0);
193 } 197 }
194 if (ret < 0) 198 if (ret < 0)
195 return -ENODEV; 199 return -ENODEV;
196 200
197 reg = it913x_read_reg_u8(state, 0xec86); 201 reg = it913x_rd_reg(state, 0xec86);
198 switch (reg) { 202 switch (reg) {
199 case 0: 203 case 0:
200 state->tun_clk_mode = reg; 204 state->tun_clk_mode = reg;
@@ -213,7 +217,7 @@ static int it913x_init_tuner(struct dvb_frontend *fe)
213 break; 217 break;
214 } 218 }
215 219
216 reg = it913x_read_reg_u8(state, 0xed03); 220 reg = it913x_rd_reg(state, 0xed03);
217 221
218 if (reg < 0) 222 if (reg < 0)
219 return -ENODEV; 223 return -ENODEV;
@@ -223,7 +227,7 @@ static int it913x_init_tuner(struct dvb_frontend *fe)
223 nv_val = 2; 227 nv_val = 2;
224 228
225 for (i = 0; i < 50; i++) { 229 for (i = 0; i < 50; i++) {
226 ret = it913x_read_reg(state, 0xed23, &b[0], sizeof(b)); 230 ret = it913x_rd_regs(state, 0xed23, &b[0], sizeof(b));
227 reg = (b[1] << 8) + b[0]; 231 reg = (b[1] << 8) + b[0];
228 if (reg > 0) 232 if (reg > 0)
229 break; 233 break;
@@ -239,7 +243,7 @@ static int it913x_init_tuner(struct dvb_frontend *fe)
239 msleep(50); 243 msleep(50);
240 else { 244 else {
241 for (i = 0; i < 50; i++) { 245 for (i = 0; i < 50; i++) {
242 reg = it913x_read_reg_u8(state, 0xec82); 246 reg = it913x_rd_reg(state, 0xec82);
243 if (reg > 0) 247 if (reg > 0)
244 break; 248 break;
245 if (reg < 0) 249 if (reg < 0)
@@ -248,12 +252,12 @@ static int it913x_init_tuner(struct dvb_frontend *fe)
248 } 252 }
249 } 253 }
250 254
251 return it913x_write_reg(state, PRO_DMOD, 0xed81, val); 255 return it913x_wr_reg(state, PRO_DMOD, 0xed81, val);
252} 256}
253 257
254static int it9137_set_tuner(struct dvb_frontend *fe) 258static int it9137_set_params(struct dvb_frontend *fe)
255{ 259{
256 struct it913x_fe_state *state = fe->tuner_priv; 260 struct it913x_state *state = fe->tuner_priv;
257 struct it913xset *set_tuner = set_it9137_template; 261 struct it913xset *set_tuner = set_it9137_template;
258 struct dtv_frontend_properties *p = &fe->dtv_property_cache; 262 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
259 u32 bandwidth = p->bandwidth_hz; 263 u32 bandwidth = p->bandwidth_hz;
@@ -358,7 +362,7 @@ static int it9137_set_tuner(struct dvb_frontend *fe)
358 } else 362 } else
359 return -EINVAL; 363 return -EINVAL;
360 364
361 reg = it913x_read_reg_u8(state, 0xed81); 365 reg = it913x_rd_reg(state, 0xed81);
362 iqik_m_cal = (u16)reg * n_div; 366 iqik_m_cal = (u16)reg * n_div;
363 367
364 if (reg < 0x20) { 368 if (reg < 0x20) {
@@ -396,7 +400,7 @@ static int it9137_set_tuner(struct dvb_frontend *fe)
396 400
397 pr_debug("low Frequency = %04x\n", freq); 401 pr_debug("low Frequency = %04x\n", freq);
398 402
399 ret = it913x_fe_script_loader(state, set_tuner); 403 ret = it913x_script_loader(state, set_tuner);
400 404
401 return (ret < 0) ? -ENODEV : 0; 405 return (ret < 0) ? -ENODEV : 0;
402} 406}
@@ -405,10 +409,10 @@ static int it9137_set_tuner(struct dvb_frontend *fe)
405/* Power Up Tuner on -> Frontend suspend off -> Tuner clk on */ 409/* Power Up Tuner on -> Frontend suspend off -> Tuner clk on */
406/* Power Down Frontend suspend on -> Tuner clk off -> Tuner off */ 410/* Power Down Frontend suspend on -> Tuner clk off -> Tuner off */
407 411
408static int it913x_fe_sleep(struct dvb_frontend *fe) 412static int it913x_sleep(struct dvb_frontend *fe)
409{ 413{
410 struct it913x_fe_state *state = fe->tuner_priv; 414 struct it913x_state *state = fe->tuner_priv;
411 return it913x_fe_script_loader(state, it9137_tuner_off); 415 return it913x_script_loader(state, it9137_tuner_off);
412} 416}
413 417
414static int it913x_release(struct dvb_frontend *fe) 418static int it913x_release(struct dvb_frontend *fe)
@@ -426,19 +430,19 @@ static const struct dvb_tuner_ops it913x_tuner_ops = {
426 430
427 .release = it913x_release, 431 .release = it913x_release,
428 432
429 .init = it913x_init_tuner, 433 .init = it913x_init,
430 .sleep = it913x_fe_sleep, 434 .sleep = it913x_sleep,
431 .set_params = it9137_set_tuner, 435 .set_params = it9137_set_params,
432}; 436};
433 437
434struct dvb_frontend *it913x_attach(struct dvb_frontend *fe, 438struct dvb_frontend *it913x_attach(struct dvb_frontend *fe,
435 struct i2c_adapter *i2c_adap, u8 i2c_addr, struct ite_config *config) 439 struct i2c_adapter *i2c_adap, u8 i2c_addr, struct ite_config *config)
436{ 440{
437 struct it913x_fe_state *state = NULL; 441 struct it913x_state *state = NULL;
438 int ret; 442 int ret;
439 443
440 /* allocate memory for the internal state */ 444 /* allocate memory for the internal state */
441 state = kzalloc(sizeof(struct it913x_fe_state), GFP_KERNEL); 445 state = kzalloc(sizeof(struct it913x_state), GFP_KERNEL);
442 if (state == NULL) 446 if (state == NULL)
443 return NULL; 447 return NULL;
444 if (config == NULL) 448 if (config == NULL)