2 * i2c tv tuner chip device driver
3 * controls all those simple 4-control-bytes style tuners.
5 * This "tuner-simple" module was split apart from the original "tuner" module.
7 #include <linux/delay.h>
9 #include <linux/videodev.h>
10 #include <media/tuner.h>
11 #include <media/v4l2-common.h>
12 #include <media/tuner-types.h>
13 #include "tuner-i2c.h"
14 #include "tuner-simple.h"
17 module_param(debug, int, 0644);
18 MODULE_PARM_DESC(debug, "enable verbose debug messages");
21 module_param(offset, int, 0664);
22 MODULE_PARM_DESC(offset, "Allows to specify an offset for tuner");
24 /* ---------------------------------------------------------------------- */
26 /* tv standard selection for Temic 4046 FM5
27 this value takes the low bits of control byte 2
28 from datasheet Rev.01, Feb.00
30 picture IF 38.9 38.9 38.9 33.95 38.9
31 sound 1 33.4 32.9 32.4 40.45 32.4
33 NICAM 33.05 32.348 33.05 33.05
35 #define TEMIC_SET_PAL_I 0x05
36 #define TEMIC_SET_PAL_DK 0x09
37 #define TEMIC_SET_PAL_L 0x0a /* SECAM ? */
38 #define TEMIC_SET_PAL_L2 0x0b /* change IF ! */
39 #define TEMIC_SET_PAL_BG 0x0c
41 /* tv tuner system standard selection for Philips FQ1216ME
42 this value takes the low bits of control byte 2
43 from datasheet "1999 Nov 16" (supersedes "1999 Mar 23")
45 picture carrier 38.90 38.90 38.90 38.90 33.95
46 colour 34.47 34.47 34.47 34.47 38.38
47 sound 1 33.40 32.40 32.90 32.40 40.45
49 NICAM 33.05 33.05 32.35 33.05 39.80
51 #define PHILIPS_SET_PAL_I 0x01 /* Bit 2 always zero !*/
52 #define PHILIPS_SET_PAL_BGDK 0x09
53 #define PHILIPS_SET_PAL_L2 0x0a
54 #define PHILIPS_SET_PAL_L 0x0b
56 /* system switching for Philips FI1216MF MK2
57 from datasheet "1996 Jul 09",
59 picture carrier 38.90 38.90 33.95
60 colour 34.47 34.37 38.38
61 sound 1 33.40 32.40 40.45
63 NICAM 33.05 33.05 39.80
65 #define PHILIPS_MF_SET_STD_BG 0x01 /* Bit 2 must be zero, Bit 3 is system output */
66 #define PHILIPS_MF_SET_STD_L 0x03 /* Used on Secam France */
67 #define PHILIPS_MF_SET_STD_LC 0x02 /* Used on SECAM L' */
71 #define TUNER_RATIO_MASK 0x06 /* Bit cb1:cb2 */
72 #define TUNER_RATIO_SELECT_50 0x00
73 #define TUNER_RATIO_SELECT_32 0x02
74 #define TUNER_RATIO_SELECT_166 0x04
75 #define TUNER_RATIO_SELECT_62 0x06
77 #define TUNER_CHARGE_PUMP 0x40 /* Bit cb6 */
81 #define TUNER_POR 0x80
83 #define TUNER_MODE 0x38
84 #define TUNER_AFC 0x07
85 #define TUNER_SIGNAL 0x07
86 #define TUNER_STEREO 0x10
88 #define TUNER_PLL_LOCKED 0x40
89 #define TUNER_STEREO_MK3 0x04
91 static DEFINE_MUTEX(tuner_simple_list_mutex);
92 static LIST_HEAD(hybrid_tuner_instance_list);
94 struct tuner_simple_priv {
97 struct tuner_i2c_props i2c_props;
98 struct list_head hybrid_tuner_instance_list;
101 struct tunertype *tun;
107 /* ---------------------------------------------------------------------- */
109 static int tuner_read_status(struct dvb_frontend *fe)
111 struct tuner_simple_priv *priv = fe->tuner_priv;
114 if (1 != tuner_i2c_xfer_recv(&priv->i2c_props, &byte, 1))
120 static inline int tuner_signal(const int status)
122 return (status & TUNER_SIGNAL) << 13;
125 static inline int tuner_stereo(const int type, const int status)
128 case TUNER_PHILIPS_FM1216ME_MK3:
129 case TUNER_PHILIPS_FM1236_MK3:
130 case TUNER_PHILIPS_FM1256_IH3:
131 case TUNER_LG_NTSC_TAPE:
132 return ((status & TUNER_SIGNAL) == TUNER_STEREO_MK3);
134 return status & TUNER_STEREO;
138 static inline int tuner_islocked(const int status)
140 return (status & TUNER_FL);
143 static inline int tuner_afcstatus(const int status)
145 return (status & TUNER_AFC) - 2;
149 static int simple_get_status(struct dvb_frontend *fe, u32 *status)
151 struct tuner_simple_priv *priv = fe->tuner_priv;
152 int tuner_status = tuner_read_status(fe);
156 if (tuner_islocked(tuner_status))
157 *status = TUNER_STATUS_LOCKED;
158 if (tuner_stereo(priv->type, tuner_status))
159 *status |= TUNER_STATUS_STEREO;
161 tuner_dbg("AFC Status: %d\n", tuner_afcstatus(tuner_status));
166 static int simple_get_rf_strength(struct dvb_frontend *fe, u16 *strength)
168 struct tuner_simple_priv *priv = fe->tuner_priv;
169 int signal = tuner_signal(tuner_read_status(fe));
173 tuner_dbg("Signal strength: %d\n", signal);
178 /* ---------------------------------------------------------------------- */
180 static inline char *tuner_param_name(enum param_type type)
185 case TUNER_PARAM_TYPE_RADIO:
188 case TUNER_PARAM_TYPE_PAL:
191 case TUNER_PARAM_TYPE_SECAM:
194 case TUNER_PARAM_TYPE_NTSC:
197 case TUNER_PARAM_TYPE_DIGITAL:
207 static struct tuner_params *simple_tuner_params(struct dvb_frontend *fe,
208 enum param_type desired_type)
210 struct tuner_simple_priv *priv = fe->tuner_priv;
211 struct tunertype *tun = priv->tun;
214 for (i = 0; i < tun->count; i++)
215 if (desired_type == tun->params[i].type)
218 /* use default tuner params if desired_type not available */
219 if (i == tun->count) {
220 tuner_dbg("desired params (%s) undefined for tuner %d\n",
221 tuner_param_name(desired_type), priv->type);
225 tuner_dbg("using tuner params #%d (%s)\n", i,
226 tuner_param_name(tun->params[i].type));
228 return &tun->params[i];
231 static int simple_config_lookup(struct dvb_frontend *fe,
232 struct tuner_params *t_params,
233 int *frequency, u8 *config, u8 *cb)
235 struct tuner_simple_priv *priv = fe->tuner_priv;
238 for (i = 0; i < t_params->count; i++) {
239 if (*frequency > t_params->ranges[i].limit)
243 if (i == t_params->count) {
244 tuner_dbg("frequency out of range (%d > %d)\n",
245 *frequency, t_params->ranges[i - 1].limit);
246 *frequency = t_params->ranges[--i].limit;
248 *config = t_params->ranges[i].config;
249 *cb = t_params->ranges[i].cb;
251 tuner_dbg("freq = %d.%02d (%d), range = %d, "
252 "config = 0x%02x, cb = 0x%02x\n",
253 *frequency / 16, *frequency % 16 * 100 / 16, *frequency,
259 /* ---------------------------------------------------------------------- */
261 static int simple_std_setup(struct dvb_frontend *fe,
262 struct analog_parameters *params,
265 struct tuner_simple_priv *priv = fe->tuner_priv;
269 /* tv norm specific stuff for multi-norm tuners */
270 switch (priv->type) {
271 case TUNER_PHILIPS_SECAM: /* FI1216MF */
272 /* 0x01 -> ??? no change ??? */
273 /* 0x02 -> PAL BDGHI / SECAM L */
274 /* 0x04 -> ??? PAL others / SECAM others ??? */
276 if (params->std & V4L2_STD_SECAM_L)
277 /* also valid for V4L2_STD_SECAM */
278 *cb |= PHILIPS_MF_SET_STD_L;
279 else if (params->std & V4L2_STD_SECAM_LC)
280 *cb |= PHILIPS_MF_SET_STD_LC;
281 else /* V4L2_STD_B|V4L2_STD_GH */
282 *cb |= PHILIPS_MF_SET_STD_BG;
285 case TUNER_TEMIC_4046FM5:
288 if (params->std & V4L2_STD_PAL_BG) {
289 *cb |= TEMIC_SET_PAL_BG;
291 } else if (params->std & V4L2_STD_PAL_I) {
292 *cb |= TEMIC_SET_PAL_I;
294 } else if (params->std & V4L2_STD_PAL_DK) {
295 *cb |= TEMIC_SET_PAL_DK;
297 } else if (params->std & V4L2_STD_SECAM_L) {
298 *cb |= TEMIC_SET_PAL_L;
303 case TUNER_PHILIPS_FQ1216ME:
306 if (params->std & (V4L2_STD_PAL_BG|V4L2_STD_PAL_DK)) {
307 *cb |= PHILIPS_SET_PAL_BGDK;
309 } else if (params->std & V4L2_STD_PAL_I) {
310 *cb |= PHILIPS_SET_PAL_I;
312 } else if (params->std & V4L2_STD_SECAM_L) {
313 *cb |= PHILIPS_SET_PAL_L;
318 case TUNER_PHILIPS_ATSC:
319 /* 0x00 -> ATSC antenna input 1 */
320 /* 0x01 -> ATSC antenna input 2 */
321 /* 0x02 -> NTSC antenna input 1 */
322 /* 0x03 -> NTSC antenna input 2 */
324 if (!(params->std & V4L2_STD_ATSC))
329 case TUNER_MICROTUNE_4042FI5:
330 /* Set the charge pump for fast tuning */
331 *config |= TUNER_CHARGE_PUMP;
334 case TUNER_PHILIPS_TUV1236D:
336 /* 0x40 -> ATSC antenna input 1 */
337 /* 0x48 -> ATSC antenna input 2 */
338 /* 0x00 -> NTSC antenna input 1 */
339 /* 0x08 -> NTSC antenna input 2 */
340 u8 buffer[4] = { 0x14, 0x00, 0x17, 0x00};
342 if (params->std & V4L2_STD_ATSC) {
346 /* set to the correct mode (analog or digital) */
347 tuneraddr = priv->i2c_props.addr;
348 priv->i2c_props.addr = 0x0a;
349 rc = tuner_i2c_xfer_send(&priv->i2c_props, &buffer[0], 2);
351 tuner_warn("i2c i/o error: rc == %d "
352 "(should be 2)\n", rc);
353 rc = tuner_i2c_xfer_send(&priv->i2c_props, &buffer[2], 2);
355 tuner_warn("i2c i/o error: rc == %d "
356 "(should be 2)\n", rc);
357 priv->i2c_props.addr = tuneraddr;
366 static int simple_post_tune(struct dvb_frontend *fe, u8 *buffer,
367 u16 div, u8 config, u8 cb)
369 struct tuner_simple_priv *priv = fe->tuner_priv;
372 switch (priv->type) {
373 case TUNER_LG_TDVS_H06XF:
374 /* Set the Auxiliary Byte. */
375 buffer[0] = buffer[2];
379 tuner_dbg("tv 0x%02x 0x%02x\n", buffer[0], buffer[1]);
381 rc = tuner_i2c_xfer_send(&priv->i2c_props, buffer, 2);
383 tuner_warn("i2c i/o error: rc == %d "
384 "(should be 2)\n", rc);
386 case TUNER_MICROTUNE_4042FI5:
388 /* FIXME - this may also work for other tuners */
389 unsigned long timeout = jiffies + msecs_to_jiffies(1);
392 /* Wait until the PLL locks */
394 if (time_after(jiffies, timeout))
396 rc = tuner_i2c_xfer_recv(&priv->i2c_props,
399 tuner_warn("i2c i/o read error: rc == %d "
400 "(should be 1)\n", rc);
403 if (status_byte & TUNER_PLL_LOCKED)
408 /* Set the charge pump for optimized phase noise figure */
409 config &= ~TUNER_CHARGE_PUMP;
410 buffer[0] = (div>>8) & 0x7f;
411 buffer[1] = div & 0xff;
414 tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
415 buffer[0], buffer[1], buffer[2], buffer[3]);
417 rc = tuner_i2c_xfer_send(&priv->i2c_props, buffer, 4);
419 tuner_warn("i2c i/o error: rc == %d "
420 "(should be 4)\n", rc);
428 static int simple_radio_bandswitch(struct dvb_frontend *fe, u8 *buffer)
430 struct tuner_simple_priv *priv = fe->tuner_priv;
432 switch (priv->type) {
433 case TUNER_TENA_9533_DI:
434 case TUNER_YMEC_TVF_5533MF:
435 tuner_dbg("This tuner doesn't have FM. "
436 "Most cards have a TEA5767 for FM\n");
438 case TUNER_PHILIPS_FM1216ME_MK3:
439 case TUNER_PHILIPS_FM1236_MK3:
440 case TUNER_PHILIPS_FMD1216ME_MK3:
441 case TUNER_LG_NTSC_TAPE:
442 case TUNER_PHILIPS_FM1256_IH3:
445 case TUNER_TNF_5335MF:
448 case TUNER_LG_PAL_FM:
451 case TUNER_THOMSON_DTT761X:
454 case TUNER_MICROTUNE_4049FM5:
463 /* ---------------------------------------------------------------------- */
465 static int simple_set_tv_freq(struct dvb_frontend *fe,
466 struct analog_parameters *params)
468 struct tuner_simple_priv *priv = fe->tuner_priv;
471 struct tunertype *tun;
474 enum param_type desired_type;
475 struct tuner_params *t_params;
479 /* IFPCoff = Video Intermediate Frequency - Vif:
480 940 =16*58.75 NTSC/J (Japan)
481 732 =16*45.75 M/N STD
482 704 =16*44 ATSC (at DVB code)
484 622.4=16*38.90 B/G D/K I, L STD
485 592 =16*37.00 D China
486 590 =16.36.875 B Australia
487 543.2=16*33.95 L' STD
488 171.2=16*10.70 FM Radio (at set_radio_freq)
491 if (params->std == V4L2_STD_NTSC_M_JP) {
493 desired_type = TUNER_PARAM_TYPE_NTSC;
494 } else if ((params->std & V4L2_STD_MN) &&
495 !(params->std & ~V4L2_STD_MN)) {
497 desired_type = TUNER_PARAM_TYPE_NTSC;
498 } else if (params->std == V4L2_STD_SECAM_LC) {
500 desired_type = TUNER_PARAM_TYPE_SECAM;
503 desired_type = TUNER_PARAM_TYPE_PAL;
506 t_params = simple_tuner_params(fe, desired_type);
508 i = simple_config_lookup(fe, t_params, ¶ms->frequency,
511 div = params->frequency + IFPCoff + offset;
513 tuner_dbg("Freq= %d.%02d MHz, V_IF=%d.%02d MHz, "
514 "Offset=%d.%02d MHz, div=%0d\n",
515 params->frequency / 16, params->frequency % 16 * 100 / 16,
516 IFPCoff / 16, IFPCoff % 16 * 100 / 16,
517 offset / 16, offset % 16 * 100 / 16, div);
519 /* tv norm specific stuff for multi-norm tuners */
520 simple_std_setup(fe, params, &config, &cb);
522 if (t_params->cb_first_if_lower_freq && div < priv->last_div) {
525 buffer[2] = (div>>8) & 0x7f;
526 buffer[3] = div & 0xff;
528 buffer[0] = (div>>8) & 0x7f;
529 buffer[1] = div & 0xff;
533 priv->last_div = div;
534 if (t_params->has_tda9887) {
535 struct v4l2_priv_tun_config tda9887_cfg;
537 int is_secam_l = (params->std & (V4L2_STD_SECAM_L |
538 V4L2_STD_SECAM_LC)) &&
539 !(params->std & ~(V4L2_STD_SECAM_L |
542 tda9887_cfg.tuner = TUNER_TDA9887;
543 tda9887_cfg.priv = &config;
545 if (params->std == V4L2_STD_SECAM_LC) {
546 if (t_params->port1_active ^ t_params->port1_invert_for_secam_lc)
547 config |= TDA9887_PORT1_ACTIVE;
548 if (t_params->port2_active ^ t_params->port2_invert_for_secam_lc)
549 config |= TDA9887_PORT2_ACTIVE;
551 if (t_params->port1_active)
552 config |= TDA9887_PORT1_ACTIVE;
553 if (t_params->port2_active)
554 config |= TDA9887_PORT2_ACTIVE;
556 if (t_params->intercarrier_mode)
557 config |= TDA9887_INTERCARRIER;
559 if (i == 0 && t_params->default_top_secam_low)
560 config |= TDA9887_TOP(t_params->default_top_secam_low);
561 else if (i == 1 && t_params->default_top_secam_mid)
562 config |= TDA9887_TOP(t_params->default_top_secam_mid);
563 else if (t_params->default_top_secam_high)
564 config |= TDA9887_TOP(t_params->default_top_secam_high);
566 if (i == 0 && t_params->default_top_low)
567 config |= TDA9887_TOP(t_params->default_top_low);
568 else if (i == 1 && t_params->default_top_mid)
569 config |= TDA9887_TOP(t_params->default_top_mid);
570 else if (t_params->default_top_high)
571 config |= TDA9887_TOP(t_params->default_top_high);
573 if (t_params->default_pll_gating_18)
574 config |= TDA9887_GATING_18;
575 i2c_clients_command(priv->i2c_props.adap, TUNER_SET_CONFIG,
578 tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
579 buffer[0], buffer[1], buffer[2], buffer[3]);
581 rc = tuner_i2c_xfer_send(&priv->i2c_props, buffer, 4);
583 tuner_warn("i2c i/o error: rc == %d (should be 4)\n", rc);
585 simple_post_tune(fe, &buffer[0], div, config, cb);
590 static int simple_set_radio_freq(struct dvb_frontend *fe,
591 struct analog_parameters *params)
593 struct tunertype *tun;
594 struct tuner_simple_priv *priv = fe->tuner_priv;
598 struct tuner_params *t_params;
599 unsigned int freq = params->frequency;
603 for (j = tun->count-1; j > 0; j--)
604 if (tun->params[j].type == TUNER_PARAM_TYPE_RADIO)
606 /* default t_params (j=0) will be used if desired type wasn't found */
607 t_params = &tun->params[j];
609 /* Select Radio 1st IF used */
610 switch (t_params->radio_if) {
611 case 0: /* 10.7 MHz */
612 freq += (unsigned int)(10.7*16000);
614 case 1: /* 33.3 MHz */
615 freq += (unsigned int)(33.3*16000);
617 case 2: /* 41.3 MHz */
618 freq += (unsigned int)(41.3*16000);
621 tuner_warn("Unsupported radio_if value %d\n",
626 /* Bandswitch byte */
627 simple_radio_bandswitch(fe, &buffer[0]);
629 buffer[2] = (t_params->ranges[0].config & ~TUNER_RATIO_MASK) |
630 TUNER_RATIO_SELECT_50; /* 50 kHz step */
632 /* Convert from 1/16 kHz V4L steps to 1/20 MHz (=50 kHz) PLL steps
633 freq * (1 Mhz / 16000 V4L steps) * (20 PLL steps / 1 MHz) =
635 div = (freq + 400) / 800;
637 if (t_params->cb_first_if_lower_freq && div < priv->last_div) {
638 buffer[0] = buffer[2];
639 buffer[1] = buffer[3];
640 buffer[2] = (div>>8) & 0x7f;
641 buffer[3] = div & 0xff;
643 buffer[0] = (div>>8) & 0x7f;
644 buffer[1] = div & 0xff;
647 tuner_dbg("radio 0x%02x 0x%02x 0x%02x 0x%02x\n",
648 buffer[0], buffer[1], buffer[2], buffer[3]);
649 priv->last_div = div;
651 if (t_params->has_tda9887) {
653 struct v4l2_priv_tun_config tda9887_cfg;
655 tda9887_cfg.tuner = TUNER_TDA9887;
656 tda9887_cfg.priv = &config;
658 if (t_params->port1_active &&
659 !t_params->port1_fm_high_sensitivity)
660 config |= TDA9887_PORT1_ACTIVE;
661 if (t_params->port2_active &&
662 !t_params->port2_fm_high_sensitivity)
663 config |= TDA9887_PORT2_ACTIVE;
664 if (t_params->intercarrier_mode)
665 config |= TDA9887_INTERCARRIER;
666 /* if (t_params->port1_set_for_fm_mono)
667 config &= ~TDA9887_PORT1_ACTIVE;*/
668 if (t_params->fm_gain_normal)
669 config |= TDA9887_GAIN_NORMAL;
670 if (t_params->radio_if == 2)
671 config |= TDA9887_RIF_41_3;
672 i2c_clients_command(priv->i2c_props.adap, TUNER_SET_CONFIG,
675 rc = tuner_i2c_xfer_send(&priv->i2c_props, buffer, 4);
677 tuner_warn("i2c i/o error: rc == %d (should be 4)\n", rc);
682 static int simple_set_params(struct dvb_frontend *fe,
683 struct analog_parameters *params)
685 struct tuner_simple_priv *priv = fe->tuner_priv;
688 switch (params->mode) {
689 case V4L2_TUNER_RADIO:
690 ret = simple_set_radio_freq(fe, params);
691 priv->frequency = params->frequency * 125 / 2;
693 case V4L2_TUNER_ANALOG_TV:
694 case V4L2_TUNER_DIGITAL_TV:
695 ret = simple_set_tv_freq(fe, params);
696 priv->frequency = params->frequency * 62500;
704 static int simple_dvb_configure(struct dvb_frontend *fe, u8 *buf,
705 const struct dvb_frontend_parameters *params)
707 struct tuner_simple_priv *priv = fe->tuner_priv;
708 struct tunertype *tun = priv->tun;
709 static struct tuner_params *t_params;
712 int ret, frequency = params->frequency / 62500;
714 t_params = simple_tuner_params(fe, TUNER_PARAM_TYPE_DIGITAL);
715 ret = simple_config_lookup(fe, t_params, &frequency, &config, &cb);
719 div = ((frequency + t_params->iffreq) * 62500 + offset +
720 tun->stepsize/2) / tun->stepsize;
727 tuner_dbg("%s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n",
728 tun->name, div, buf[0], buf[1], buf[2], buf[3]);
730 /* calculate the frequency we set it to */
731 return (div * tun->stepsize) - t_params->iffreq;
734 static int simple_dvb_calc_regs(struct dvb_frontend *fe,
735 struct dvb_frontend_parameters *params,
736 u8 *buf, int buf_len)
738 struct tuner_simple_priv *priv = fe->tuner_priv;
745 ret = simple_dvb_configure(fe, buf+1, params);
751 buf[0] = priv->i2c_props.addr;
753 priv->frequency = frequency;
754 priv->bandwidth = (fe->ops.info.type == FE_OFDM) ?
755 params->u.ofdm.bandwidth : 0;
760 static int simple_dvb_set_params(struct dvb_frontend *fe,
761 struct dvb_frontend_parameters *params)
763 struct tuner_simple_priv *priv = fe->tuner_priv;
764 u32 prev_freq, prev_bw;
768 if (priv->i2c_props.adap == NULL)
771 prev_freq = priv->frequency;
772 prev_bw = priv->bandwidth;
774 ret = simple_dvb_calc_regs(fe, params, buf, 5);
778 /* put analog demod in standby when tuning digital */
779 if (fe->ops.analog_ops.standby)
780 fe->ops.analog_ops.standby(fe);
782 if (fe->ops.i2c_gate_ctrl)
783 fe->ops.i2c_gate_ctrl(fe, 1);
785 /* buf[0] contains the i2c address, but *
786 * we already have it in i2c_props.addr */
787 ret = tuner_i2c_xfer_send(&priv->i2c_props, buf+1, 4);
793 /* calc_regs sets frequency and bandwidth. if we failed, unset them */
794 priv->frequency = prev_freq;
795 priv->bandwidth = prev_bw;
800 static int simple_release(struct dvb_frontend *fe)
802 struct tuner_simple_priv *priv = fe->tuner_priv;
804 mutex_lock(&tuner_simple_list_mutex);
807 hybrid_tuner_release_state(priv);
809 mutex_unlock(&tuner_simple_list_mutex);
811 fe->tuner_priv = NULL;
816 static int simple_get_frequency(struct dvb_frontend *fe, u32 *frequency)
818 struct tuner_simple_priv *priv = fe->tuner_priv;
819 *frequency = priv->frequency;
823 static int simple_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
825 struct tuner_simple_priv *priv = fe->tuner_priv;
826 *bandwidth = priv->bandwidth;
830 static struct dvb_tuner_ops simple_tuner_ops = {
831 .set_analog_params = simple_set_params,
832 .set_params = simple_dvb_set_params,
833 .calc_regs = simple_dvb_calc_regs,
834 .release = simple_release,
835 .get_frequency = simple_get_frequency,
836 .get_bandwidth = simple_get_bandwidth,
837 .get_status = simple_get_status,
838 .get_rf_strength = simple_get_rf_strength,
841 struct dvb_frontend *simple_tuner_attach(struct dvb_frontend *fe,
842 struct i2c_adapter *i2c_adap,
846 struct tuner_simple_priv *priv = NULL;
849 if (type >= tuner_count) {
850 printk(KERN_WARNING "%s: invalid tuner type: %d (max: %d)\n",
851 __FUNCTION__, type, tuner_count-1);
855 mutex_lock(&tuner_simple_list_mutex);
857 instance = hybrid_tuner_request_state(struct tuner_simple_priv, priv,
858 hybrid_tuner_instance_list,
863 mutex_unlock(&tuner_simple_list_mutex);
867 fe->tuner_priv = priv;
870 priv->tun = &tuners[type];
873 fe->tuner_priv = priv;
877 mutex_unlock(&tuner_simple_list_mutex);
879 memcpy(&fe->ops.tuner_ops, &simple_tuner_ops,
880 sizeof(struct dvb_tuner_ops));
882 tuner_info("type set to %d (%s)\n", type, priv->tun->name);
884 strlcpy(fe->ops.tuner_ops.info.name, priv->tun->name,
885 sizeof(fe->ops.tuner_ops.info.name));
889 EXPORT_SYMBOL_GPL(simple_tuner_attach);
891 MODULE_DESCRIPTION("Simple 4-control-bytes style tuner driver");
892 MODULE_AUTHOR("Ralph Metzler, Gerd Knorr, Gunther Mayer");
893 MODULE_LICENSE("GPL");
896 * Overrides for Emacs so that we follow Linus's tabbing style.
897 * ---------------------------------------------------------------------------