diff options
author | Trent Piepho <xyzzy@speakeasy.org> | 2009-06-11 18:31:22 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-09-12 11:17:52 -0400 |
commit | 016e53de0a5929c7b2ce2661e3af240e7f85fd55 (patch) | |
tree | b049325fe2abe8847b4e189a284d6b0b60554398 /drivers/media/dvb/b2c2 | |
parent | 6d67c9717bb71fd23a1f87c464df3ac886759cd0 (diff) |
V4L/DVB (12293): b2c2: Use dvb-pll for Skystar2 rev 2.3 and rev 2.6
The code in skystar23_samsung_tbdu18132_tuner_set_params() and
samsung_tbmu24112_tuner_set_params() is equivalent to what the dvb-pll code
does. There could be an issue because the dvb-pll code will probe to check
for the tuner, while the previous code didn't do any checks.
Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/b2c2')
-rw-r--r-- | drivers/media/dvb/b2c2/flexcop-fe-tuner.c | 105 |
1 files changed, 31 insertions, 74 deletions
diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c index c35661a5ab27..5bf9049c6c00 100644 --- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c +++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c | |||
@@ -66,7 +66,7 @@ static int flexcop_sleep(struct dvb_frontend* fe) | |||
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | /* SkyStar2 DVB-S rev 2.3 */ | 68 | /* SkyStar2 DVB-S rev 2.3 */ |
69 | #if FE_SUPPORTED(MT312) | 69 | #if FE_SUPPORTED(MT312) && FE_SUPPORTED(PLL) |
70 | static int flexcop_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone) | 70 | static int flexcop_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone) |
71 | { | 71 | { |
72 | /* u16 wz_half_period_for_45_mhz[] = { 0x01ff, 0x0154, 0x00ff, 0x00cc }; */ | 72 | /* u16 wz_half_period_for_45_mhz[] = { 0x01ff, 0x0154, 0x00ff, 0x00cc }; */ |
@@ -155,55 +155,34 @@ static struct mt312_config skystar23_samsung_tbdu18132_config = { | |||
155 | .demod_address = 0x0e, | 155 | .demod_address = 0x0e, |
156 | }; | 156 | }; |
157 | 157 | ||
158 | static int skystar23_samsung_tbdu18132_tuner_set_params(struct dvb_frontend *fe, | ||
159 | struct dvb_frontend_parameters *params) | ||
160 | { | ||
161 | u8 buf[4]; | ||
162 | u32 div; | ||
163 | struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, | ||
164 | .len = sizeof(buf) }; | ||
165 | struct flexcop_device *fc = fe->dvb->priv; | ||
166 | div = (params->frequency + (125/2)) / 125; | ||
167 | |||
168 | buf[0] = (div >> 8) & 0x7f; | ||
169 | buf[1] = (div >> 0) & 0xff; | ||
170 | buf[2] = 0x84 | ((div >> 10) & 0x60); | ||
171 | buf[3] = 0x80; | ||
172 | |||
173 | if (params->frequency < 1550000) | ||
174 | buf[3] |= 0x02; | ||
175 | |||
176 | if (fe->ops.i2c_gate_ctrl) | ||
177 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
178 | if (i2c_transfer(&fc->fc_i2c_adap[0].i2c_adap, &msg, 1) != 1) | ||
179 | return -EIO; | ||
180 | return 0; | ||
181 | } | ||
182 | |||
183 | static int skystar2_rev23_attach(struct flexcop_device *fc, | 158 | static int skystar2_rev23_attach(struct flexcop_device *fc, |
184 | struct i2c_adapter *i2c) | 159 | struct i2c_adapter *i2c) |
185 | { | 160 | { |
161 | struct dvb_frontend_ops *ops; | ||
162 | |||
186 | fc->fe = dvb_attach(mt312_attach, &skystar23_samsung_tbdu18132_config, i2c); | 163 | fc->fe = dvb_attach(mt312_attach, &skystar23_samsung_tbdu18132_config, i2c); |
187 | if (fc->fe != NULL) { | 164 | if (!fc->fe) |
188 | struct dvb_frontend_ops *ops = &fc->fe->ops; | 165 | return 0; |
189 | ops->tuner_ops.set_params = | 166 | |
190 | skystar23_samsung_tbdu18132_tuner_set_params; | 167 | if (!dvb_attach(dvb_pll_attach, fc->fe, 0x61, i2c, |
191 | ops->diseqc_send_master_cmd = flexcop_diseqc_send_master_cmd; | 168 | DVB_PLL_SAMSUNG_TBDU18132)) |
192 | ops->diseqc_send_burst = flexcop_diseqc_send_burst; | 169 | return 0; |
193 | ops->set_tone = flexcop_set_tone; | 170 | |
194 | ops->set_voltage = flexcop_set_voltage; | 171 | ops = &fc->fe->ops; |
195 | fc->fe_sleep = ops->sleep; | 172 | ops->diseqc_send_master_cmd = flexcop_diseqc_send_master_cmd; |
196 | ops->sleep = flexcop_sleep; | 173 | ops->diseqc_send_burst = flexcop_diseqc_send_burst; |
197 | return 1; | 174 | ops->set_tone = flexcop_set_tone; |
198 | } | 175 | ops->set_voltage = flexcop_set_voltage; |
199 | return 0; | 176 | fc->fe_sleep = ops->sleep; |
177 | ops->sleep = flexcop_sleep; | ||
178 | return 1; | ||
200 | } | 179 | } |
201 | #else | 180 | #else |
202 | #define skystar2_rev23_attach NULL | 181 | #define skystar2_rev23_attach NULL |
203 | #endif | 182 | #endif |
204 | 183 | ||
205 | /* SkyStar2 DVB-S rev 2.6 */ | 184 | /* SkyStar2 DVB-S rev 2.6 */ |
206 | #if FE_SUPPORTED(STV0299) | 185 | #if FE_SUPPORTED(STV0299) && FE_SUPPORTED(PLL) |
207 | static int samsung_tbmu24112_set_symbol_rate(struct dvb_frontend *fe, | 186 | static int samsung_tbmu24112_set_symbol_rate(struct dvb_frontend *fe, |
208 | u32 srate, u32 ratio) | 187 | u32 srate, u32 ratio) |
209 | { | 188 | { |
@@ -232,31 +211,6 @@ static int samsung_tbmu24112_set_symbol_rate(struct dvb_frontend *fe, | |||
232 | return 0; | 211 | return 0; |
233 | } | 212 | } |
234 | 213 | ||
235 | static int samsung_tbmu24112_tuner_set_params(struct dvb_frontend *fe, | ||
236 | struct dvb_frontend_parameters *params) | ||
237 | { | ||
238 | u8 buf[4]; | ||
239 | u32 div; | ||
240 | struct i2c_msg msg = { | ||
241 | .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) }; | ||
242 | struct flexcop_device *fc = fe->dvb->priv; | ||
243 | div = params->frequency / 125; | ||
244 | |||
245 | buf[0] = (div >> 8) & 0x7f; | ||
246 | buf[1] = div & 0xff; | ||
247 | buf[2] = 0x84; /* 0xC4 */ | ||
248 | buf[3] = 0x08; | ||
249 | |||
250 | if (params->frequency < 1500000) | ||
251 | buf[3] |= 0x10; | ||
252 | |||
253 | if (fe->ops.i2c_gate_ctrl) | ||
254 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
255 | if (i2c_transfer(&fc->fc_i2c_adap[0].i2c_adap, &msg, 1) != 1) | ||
256 | return -EIO; | ||
257 | return 0; | ||
258 | } | ||
259 | |||
260 | static u8 samsung_tbmu24112_inittab[] = { | 214 | static u8 samsung_tbmu24112_inittab[] = { |
261 | 0x01, 0x15, | 215 | 0x01, 0x15, |
262 | 0x02, 0x30, | 216 | 0x02, 0x30, |
@@ -318,15 +272,18 @@ static int skystar2_rev26_attach(struct flexcop_device *fc, | |||
318 | struct i2c_adapter *i2c) | 272 | struct i2c_adapter *i2c) |
319 | { | 273 | { |
320 | fc->fe = dvb_attach(stv0299_attach, &samsung_tbmu24112_config, i2c); | 274 | fc->fe = dvb_attach(stv0299_attach, &samsung_tbmu24112_config, i2c); |
321 | if (fc->fe != NULL) { | 275 | if (!fc->fe) |
322 | struct dvb_frontend_ops *ops = &fc->fe->ops; | 276 | return 0; |
323 | ops->tuner_ops.set_params = samsung_tbmu24112_tuner_set_params; | 277 | |
324 | ops->set_voltage = flexcop_set_voltage; | 278 | if (!dvb_attach(dvb_pll_attach, fc->fe, 0x61, i2c, |
325 | fc->fe_sleep = ops->sleep; | 279 | DVB_PLL_SAMSUNG_TBMU24112)) |
326 | ops->sleep = flexcop_sleep; | 280 | return 0; |
327 | return 1; | 281 | |
328 | } | 282 | fc->fe->ops.set_voltage = flexcop_set_voltage; |
329 | return 0; | 283 | fc->fe_sleep = fc->fe->ops.sleep; |
284 | fc->fe->ops.sleep = flexcop_sleep; | ||
285 | return 1; | ||
286 | |||
330 | } | 287 | } |
331 | #else | 288 | #else |
332 | #define skystar2_rev26_attach NULL | 289 | #define skystar2_rev26_attach NULL |