V4L/DVB (6133): tuner-simple: convert from tuner sub-driver into dvb_frontend module
[powerpc.git] / drivers / media / video / tuner-simple.c
1 /*
2  * i2c tv tuner chip device driver
3  * controls all those simple 4-control-bytes style tuners.
4  *
5  * This "tuner-simple" module was split apart from the original "tuner" module.
6  */
7 #include <linux/delay.h>
8 #include <linux/i2c.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"
15
16 static int debug = 0;
17 module_param(debug, int, 0644);
18 MODULE_PARM_DESC(debug, "enable verbose debug messages");
19
20 #define PREFIX "tuner-simple "
21
22 static int offset = 0;
23 module_param(offset, int, 0664);
24 MODULE_PARM_DESC(offset,"Allows to specify an offset for tuner");
25
26 /* ---------------------------------------------------------------------- */
27
28 /* tv standard selection for Temic 4046 FM5
29    this value takes the low bits of control byte 2
30    from datasheet Rev.01, Feb.00
31      standard     BG      I       L       L2      D
32      picture IF   38.9    38.9    38.9    33.95   38.9
33      sound 1      33.4    32.9    32.4    40.45   32.4
34      sound 2      33.16
35      NICAM        33.05   32.348  33.05           33.05
36  */
37 #define TEMIC_SET_PAL_I         0x05
38 #define TEMIC_SET_PAL_DK        0x09
39 #define TEMIC_SET_PAL_L         0x0a // SECAM ?
40 #define TEMIC_SET_PAL_L2        0x0b // change IF !
41 #define TEMIC_SET_PAL_BG        0x0c
42
43 /* tv tuner system standard selection for Philips FQ1216ME
44    this value takes the low bits of control byte 2
45    from datasheet "1999 Nov 16" (supersedes "1999 Mar 23")
46      standard           BG      DK      I       L       L`
47      picture carrier    38.90   38.90   38.90   38.90   33.95
48      colour             34.47   34.47   34.47   34.47   38.38
49      sound 1            33.40   32.40   32.90   32.40   40.45
50      sound 2            33.16   -       -       -       -
51      NICAM              33.05   33.05   32.35   33.05   39.80
52  */
53 #define PHILIPS_SET_PAL_I       0x01 /* Bit 2 always zero !*/
54 #define PHILIPS_SET_PAL_BGDK    0x09
55 #define PHILIPS_SET_PAL_L2      0x0a
56 #define PHILIPS_SET_PAL_L       0x0b
57
58 /* system switching for Philips FI1216MF MK2
59    from datasheet "1996 Jul 09",
60     standard         BG     L      L'
61     picture carrier  38.90  38.90  33.95
62     colour           34.47  34.37  38.38
63     sound 1          33.40  32.40  40.45
64     sound 2          33.16  -      -
65     NICAM            33.05  33.05  39.80
66  */
67 #define PHILIPS_MF_SET_STD_BG   0x01 /* Bit 2 must be zero, Bit 3 is system output */
68 #define PHILIPS_MF_SET_STD_L    0x03 /* Used on Secam France */
69 #define PHILIPS_MF_SET_STD_LC   0x02 /* Used on SECAM L' */
70
71 /* Control byte */
72
73 #define TUNER_RATIO_MASK        0x06 /* Bit cb1:cb2 */
74 #define TUNER_RATIO_SELECT_50   0x00
75 #define TUNER_RATIO_SELECT_32   0x02
76 #define TUNER_RATIO_SELECT_166  0x04
77 #define TUNER_RATIO_SELECT_62   0x06
78
79 #define TUNER_CHARGE_PUMP       0x40  /* Bit cb6 */
80
81 /* Status byte */
82
83 #define TUNER_POR         0x80
84 #define TUNER_FL          0x40
85 #define TUNER_MODE        0x38
86 #define TUNER_AFC         0x07
87 #define TUNER_SIGNAL      0x07
88 #define TUNER_STEREO      0x10
89
90 #define TUNER_PLL_LOCKED   0x40
91 #define TUNER_STEREO_MK3   0x04
92
93 struct tuner_simple_priv {
94         u16 last_div;
95         struct tuner_i2c_props i2c_props;
96
97         unsigned int type;
98         struct tunertype *tun;
99
100         u32 frequency;
101 };
102
103 /* ---------------------------------------------------------------------- */
104
105 static int tuner_getstatus(struct dvb_frontend *fe)
106 {
107         struct tuner_simple_priv *priv = fe->tuner_priv;
108         unsigned char byte;
109
110         if (1 != tuner_i2c_xfer_recv(&priv->i2c_props,&byte,1))
111                 return 0;
112
113         return byte;
114 }
115
116 static int tuner_signal(struct dvb_frontend *fe)
117 {
118         return (tuner_getstatus(fe) & TUNER_SIGNAL) << 13;
119 }
120
121 static int tuner_stereo(struct dvb_frontend *fe)
122 {
123         struct tuner_simple_priv *priv = fe->tuner_priv;
124
125         int stereo, status;
126
127         status = tuner_getstatus(fe);
128
129         switch (priv->type) {
130                 case TUNER_PHILIPS_FM1216ME_MK3:
131                 case TUNER_PHILIPS_FM1236_MK3:
132                 case TUNER_PHILIPS_FM1256_IH3:
133                 case TUNER_LG_NTSC_TAPE:
134                         stereo = ((status & TUNER_SIGNAL) == TUNER_STEREO_MK3);
135                         break;
136                 default:
137                         stereo = status & TUNER_STEREO;
138         }
139
140         return stereo;
141 }
142
143
144 static int simple_get_status(struct dvb_frontend *fe, u32 *status)
145 {
146         struct tuner_simple_priv *priv = fe->tuner_priv;
147         int signal = tuner_signal(fe);
148
149         *status = 0;
150
151         if (signal)
152                 *status = TUNER_STATUS_LOCKED;
153         if (tuner_stereo(fe))
154                 *status |= TUNER_STATUS_STEREO;
155
156         tuner_dbg("tuner-simple: Signal strength: %d\n", signal);
157
158         return 0;
159 }
160
161 /* ---------------------------------------------------------------------- */
162
163 static int simple_set_tv_freq(struct dvb_frontend *fe,
164                               struct analog_parameters *params)
165 {
166         struct tuner_simple_priv *priv = fe->tuner_priv;
167         u8 config, cb, tuneraddr;
168         u16 div;
169         struct tunertype *tun;
170         u8 buffer[4];
171         int rc, IFPCoff, i, j;
172         enum param_type desired_type;
173         struct tuner_params *t_params;
174
175         tun = priv->tun;
176
177         /* IFPCoff = Video Intermediate Frequency - Vif:
178                 940  =16*58.75  NTSC/J (Japan)
179                 732  =16*45.75  M/N STD
180                 704  =16*44     ATSC (at DVB code)
181                 632  =16*39.50  I U.K.
182                 622.4=16*38.90  B/G D/K I, L STD
183                 592  =16*37.00  D China
184                 590  =16.36.875 B Australia
185                 543.2=16*33.95  L' STD
186                 171.2=16*10.70  FM Radio (at set_radio_freq)
187         */
188
189         if (params->std == V4L2_STD_NTSC_M_JP) {
190                 IFPCoff      = 940;
191                 desired_type = TUNER_PARAM_TYPE_NTSC;
192         } else if ((params->std & V4L2_STD_MN) &&
193                   !(params->std & ~V4L2_STD_MN)) {
194                 IFPCoff      = 732;
195                 desired_type = TUNER_PARAM_TYPE_NTSC;
196         } else if (params->std == V4L2_STD_SECAM_LC) {
197                 IFPCoff      = 543;
198                 desired_type = TUNER_PARAM_TYPE_SECAM;
199         } else {
200                 IFPCoff      = 623;
201                 desired_type = TUNER_PARAM_TYPE_PAL;
202         }
203
204         for (j = 0; j < tun->count-1; j++) {
205                 if (desired_type != tun->params[j].type)
206                         continue;
207                 break;
208         }
209         /* use default tuner_t_params if desired_type not available */
210         if (desired_type != tun->params[j].type) {
211                 tuner_dbg("IFPCoff = %d: tuner_t_params undefined for tuner %d\n",
212                           IFPCoff, priv->type);
213                 j = 0;
214         }
215         t_params = &tun->params[j];
216
217         for (i = 0; i < t_params->count; i++) {
218                 if (params->frequency > t_params->ranges[i].limit)
219                         continue;
220                 break;
221         }
222         if (i == t_params->count) {
223                 tuner_dbg("TV frequency out of range (%d > %d)",
224                                 params->frequency, t_params->ranges[i - 1].limit);
225                 params->frequency = t_params->ranges[--i].limit;
226         }
227         config = t_params->ranges[i].config;
228         cb     = t_params->ranges[i].cb;
229         /*  i == 0 -> VHF_LO
230          *  i == 1 -> VHF_HI
231          *  i == 2 -> UHF     */
232         tuner_dbg("tv: param %d, range %d\n",j,i);
233
234         div=params->frequency + IFPCoff + offset;
235
236         tuner_dbg("Freq= %d.%02d MHz, V_IF=%d.%02d MHz, Offset=%d.%02d MHz, div=%0d\n",
237                                         params->frequency / 16, params->frequency % 16 * 100 / 16,
238                                         IFPCoff / 16, IFPCoff % 16 * 100 / 16,
239                                         offset / 16, offset % 16 * 100 / 16,
240                                         div);
241
242         /* tv norm specific stuff for multi-norm tuners */
243         switch (priv->type) {
244         case TUNER_PHILIPS_SECAM: // FI1216MF
245                 /* 0x01 -> ??? no change ??? */
246                 /* 0x02 -> PAL BDGHI / SECAM L */
247                 /* 0x04 -> ??? PAL others / SECAM others ??? */
248                 cb &= ~0x03;
249                 if (params->std & V4L2_STD_SECAM_L) //also valid for V4L2_STD_SECAM
250                         cb |= PHILIPS_MF_SET_STD_L;
251                 else if (params->std & V4L2_STD_SECAM_LC)
252                         cb |= PHILIPS_MF_SET_STD_LC;
253                 else /* V4L2_STD_B|V4L2_STD_GH */
254                         cb |= PHILIPS_MF_SET_STD_BG;
255                 break;
256
257         case TUNER_TEMIC_4046FM5:
258                 cb &= ~0x0f;
259
260                 if (params->std & V4L2_STD_PAL_BG) {
261                         cb |= TEMIC_SET_PAL_BG;
262
263                 } else if (params->std & V4L2_STD_PAL_I) {
264                         cb |= TEMIC_SET_PAL_I;
265
266                 } else if (params->std & V4L2_STD_PAL_DK) {
267                         cb |= TEMIC_SET_PAL_DK;
268
269                 } else if (params->std & V4L2_STD_SECAM_L) {
270                         cb |= TEMIC_SET_PAL_L;
271
272                 }
273                 break;
274
275         case TUNER_PHILIPS_FQ1216ME:
276                 cb &= ~0x0f;
277
278                 if (params->std & (V4L2_STD_PAL_BG|V4L2_STD_PAL_DK)) {
279                         cb |= PHILIPS_SET_PAL_BGDK;
280
281                 } else if (params->std & V4L2_STD_PAL_I) {
282                         cb |= PHILIPS_SET_PAL_I;
283
284                 } else if (params->std & V4L2_STD_SECAM_L) {
285                         cb |= PHILIPS_SET_PAL_L;
286
287                 }
288                 break;
289
290         case TUNER_PHILIPS_ATSC:
291                 /* 0x00 -> ATSC antenna input 1 */
292                 /* 0x01 -> ATSC antenna input 2 */
293                 /* 0x02 -> NTSC antenna input 1 */
294                 /* 0x03 -> NTSC antenna input 2 */
295                 cb &= ~0x03;
296                 if (!(params->std & V4L2_STD_ATSC))
297                         cb |= 2;
298                 /* FIXME: input */
299                 break;
300
301         case TUNER_MICROTUNE_4042FI5:
302                 /* Set the charge pump for fast tuning */
303                 config |= TUNER_CHARGE_PUMP;
304                 break;
305
306         case TUNER_PHILIPS_TUV1236D:
307                 /* 0x40 -> ATSC antenna input 1 */
308                 /* 0x48 -> ATSC antenna input 2 */
309                 /* 0x00 -> NTSC antenna input 1 */
310                 /* 0x08 -> NTSC antenna input 2 */
311                 buffer[0] = 0x14;
312                 buffer[1] = 0x00;
313                 buffer[2] = 0x17;
314                 buffer[3] = 0x00;
315                 cb &= ~0x40;
316                 if (params->std & V4L2_STD_ATSC) {
317                         cb |= 0x40;
318                         buffer[1] = 0x04;
319                 }
320                 /* set to the correct mode (analog or digital) */
321                 tuneraddr = priv->i2c_props.addr;
322                 priv->i2c_props.addr = 0x0a;
323                 if (2 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,&buffer[0],2)))
324                         tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc);
325                 if (2 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,&buffer[2],2)))
326                         tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc);
327                 priv->i2c_props.addr = tuneraddr;
328                 /* FIXME: input */
329                 break;
330         }
331
332         if (t_params->cb_first_if_lower_freq && div < priv->last_div) {
333                 buffer[0] = config;
334                 buffer[1] = cb;
335                 buffer[2] = (div>>8) & 0x7f;
336                 buffer[3] = div      & 0xff;
337         } else {
338                 buffer[0] = (div>>8) & 0x7f;
339                 buffer[1] = div      & 0xff;
340                 buffer[2] = config;
341                 buffer[3] = cb;
342         }
343         priv->last_div = div;
344         if (t_params->has_tda9887) {
345                 int config = 0;
346                 int is_secam_l = (params->std & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC)) &&
347                         !(params->std & ~(V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC));
348
349                 if (params->std == V4L2_STD_SECAM_LC) {
350                         if (t_params->port1_active ^ t_params->port1_invert_for_secam_lc)
351                                 config |= TDA9887_PORT1_ACTIVE;
352                         if (t_params->port2_active ^ t_params->port2_invert_for_secam_lc)
353                                 config |= TDA9887_PORT2_ACTIVE;
354                 }
355                 else {
356                         if (t_params->port1_active)
357                                 config |= TDA9887_PORT1_ACTIVE;
358                         if (t_params->port2_active)
359                                 config |= TDA9887_PORT2_ACTIVE;
360                 }
361                 if (t_params->intercarrier_mode)
362                         config |= TDA9887_INTERCARRIER;
363                 if (is_secam_l) {
364                         if (i == 0 && t_params->default_top_secam_low)
365                                 config |= TDA9887_TOP(t_params->default_top_secam_low);
366                         else if (i == 1 && t_params->default_top_secam_mid)
367                                 config |= TDA9887_TOP(t_params->default_top_secam_mid);
368                         else if (t_params->default_top_secam_high)
369                                 config |= TDA9887_TOP(t_params->default_top_secam_high);
370                 }
371                 else {
372                         if (i == 0 && t_params->default_top_low)
373                                 config |= TDA9887_TOP(t_params->default_top_low);
374                         else if (i == 1 && t_params->default_top_mid)
375                                 config |= TDA9887_TOP(t_params->default_top_mid);
376                         else if (t_params->default_top_high)
377                                 config |= TDA9887_TOP(t_params->default_top_high);
378                 }
379                 if (t_params->default_pll_gating_18)
380                         config |= TDA9887_GATING_18;
381                 i2c_clients_command(priv->i2c_props.adap, TDA9887_SET_CONFIG, &config);
382         }
383         tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
384                   buffer[0],buffer[1],buffer[2],buffer[3]);
385
386         if (4 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,buffer,4)))
387                 tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc);
388
389         switch (priv->type) {
390         case TUNER_LG_TDVS_H06XF:
391                 /* Set the Auxiliary Byte. */
392                 buffer[0] = buffer[2];
393                 buffer[0] &= ~0x20;
394                 buffer[0] |= 0x18;
395                 buffer[1] = 0x20;
396                 tuner_dbg("tv 0x%02x 0x%02x\n",buffer[0],buffer[1]);
397
398                 if (2 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,buffer,2)))
399                         tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc);
400                 break;
401         case TUNER_MICROTUNE_4042FI5:
402         {
403                 // FIXME - this may also work for other tuners
404                 unsigned long timeout = jiffies + msecs_to_jiffies(1);
405                 u8 status_byte = 0;
406
407                 /* Wait until the PLL locks */
408                 for (;;) {
409                         if (time_after(jiffies,timeout))
410                                 return 0;
411                         if (1 != (rc = tuner_i2c_xfer_recv(&priv->i2c_props,&status_byte,1))) {
412                                 tuner_warn("i2c i/o read error: rc == %d (should be 1)\n",rc);
413                                 break;
414                         }
415                         if (status_byte & TUNER_PLL_LOCKED)
416                                 break;
417                         udelay(10);
418                 }
419
420                 /* Set the charge pump for optimized phase noise figure */
421                 config &= ~TUNER_CHARGE_PUMP;
422                 buffer[0] = (div>>8) & 0x7f;
423                 buffer[1] = div      & 0xff;
424                 buffer[2] = config;
425                 buffer[3] = cb;
426                 tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
427                           buffer[0],buffer[1],buffer[2],buffer[3]);
428
429                 if (4 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,buffer,4)))
430                         tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc);
431                 break;
432         }
433         }
434         return 0;
435 }
436
437 static int simple_set_radio_freq(struct dvb_frontend *fe,
438                                  struct analog_parameters *params)
439 {
440         struct tunertype *tun;
441         struct tuner_simple_priv *priv = fe->tuner_priv;
442         u8 buffer[4];
443         u16 div;
444         int rc, j;
445         struct tuner_params *t_params;
446         unsigned int freq = params->frequency;
447
448         tun = priv->tun;
449
450         for (j = tun->count-1; j > 0; j--)
451                 if (tun->params[j].type == TUNER_PARAM_TYPE_RADIO)
452                         break;
453         /* default t_params (j=0) will be used if desired type wasn't found */
454         t_params = &tun->params[j];
455
456         /* Select Radio 1st IF used */
457         switch (t_params->radio_if) {
458         case 0: /* 10.7 MHz */
459                 freq += (unsigned int)(10.7*16000);
460                 break;
461         case 1: /* 33.3 MHz */
462                 freq += (unsigned int)(33.3*16000);
463                 break;
464         case 2: /* 41.3 MHz */
465                 freq += (unsigned int)(41.3*16000);
466                 break;
467         default:
468                 tuner_warn("Unsupported radio_if value %d\n", t_params->radio_if);
469                 return 0;
470         }
471
472         /* Bandswitch byte */
473         switch (priv->type) {
474         case TUNER_TENA_9533_DI:
475         case TUNER_YMEC_TVF_5533MF:
476                 tuner_dbg("This tuner doesn't have FM. Most cards have a TEA5767 for FM\n");
477                 return 0;
478         case TUNER_PHILIPS_FM1216ME_MK3:
479         case TUNER_PHILIPS_FM1236_MK3:
480         case TUNER_PHILIPS_FMD1216ME_MK3:
481         case TUNER_LG_NTSC_TAPE:
482         case TUNER_PHILIPS_FM1256_IH3:
483                 buffer[3] = 0x19;
484                 break;
485         case TUNER_TNF_5335MF:
486                 buffer[3] = 0x11;
487                 break;
488         case TUNER_LG_PAL_FM:
489                 buffer[3] = 0xa5;
490                 break;
491         case TUNER_THOMSON_DTT761X:
492                 buffer[3] = 0x39;
493                 break;
494         case TUNER_MICROTUNE_4049FM5:
495         default:
496                 buffer[3] = 0xa4;
497                 break;
498         }
499
500         buffer[2] = (t_params->ranges[0].config & ~TUNER_RATIO_MASK) |
501                     TUNER_RATIO_SELECT_50; /* 50 kHz step */
502
503         /* Convert from 1/16 kHz V4L steps to 1/20 MHz (=50 kHz) PLL steps
504            freq * (1 Mhz / 16000 V4L steps) * (20 PLL steps / 1 MHz) =
505            freq * (1/800) */
506         div = (freq + 400) / 800;
507
508         if (t_params->cb_first_if_lower_freq && div < priv->last_div) {
509                 buffer[0] = buffer[2];
510                 buffer[1] = buffer[3];
511                 buffer[2] = (div>>8) & 0x7f;
512                 buffer[3] = div      & 0xff;
513         } else {
514                 buffer[0] = (div>>8) & 0x7f;
515                 buffer[1] = div      & 0xff;
516         }
517
518         tuner_dbg("radio 0x%02x 0x%02x 0x%02x 0x%02x\n",
519                buffer[0],buffer[1],buffer[2],buffer[3]);
520         priv->last_div = div;
521
522         if (t_params->has_tda9887) {
523                 int config = 0;
524                 if (t_params->port1_active && !t_params->port1_fm_high_sensitivity)
525                         config |= TDA9887_PORT1_ACTIVE;
526                 if (t_params->port2_active && !t_params->port2_fm_high_sensitivity)
527                         config |= TDA9887_PORT2_ACTIVE;
528                 if (t_params->intercarrier_mode)
529                         config |= TDA9887_INTERCARRIER;
530 /*              if (t_params->port1_set_for_fm_mono)
531                         config &= ~TDA9887_PORT1_ACTIVE;*/
532                 if (t_params->fm_gain_normal)
533                         config |= TDA9887_GAIN_NORMAL;
534                 if (t_params->radio_if == 2)
535                         config |= TDA9887_RIF_41_3;
536                 i2c_clients_command(priv->i2c_props.adap, TDA9887_SET_CONFIG, &config);
537         }
538         if (4 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,buffer,4)))
539                 tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc);
540
541         return 0;
542 }
543
544 static int simple_set_params(struct dvb_frontend *fe,
545                              struct analog_parameters *params)
546 {
547         struct tuner_simple_priv *priv = fe->tuner_priv;
548         int ret = -EINVAL;
549
550         switch (params->mode) {
551         case V4L2_TUNER_RADIO:
552                 ret = simple_set_radio_freq(fe, params);
553                 priv->frequency = params->frequency * 125 / 2;
554                 break;
555         case V4L2_TUNER_ANALOG_TV:
556         case V4L2_TUNER_DIGITAL_TV:
557                 ret = simple_set_tv_freq(fe, params);
558                 priv->frequency = params->frequency * 62500;
559                 break;
560         }
561
562         return ret;
563 }
564
565
566 static int simple_release(struct dvb_frontend *fe)
567 {
568         kfree(fe->tuner_priv);
569         fe->tuner_priv = NULL;
570
571         return 0;
572 }
573
574 static int simple_get_frequency(struct dvb_frontend *fe, u32 *frequency)
575 {
576         struct tuner_simple_priv *priv = fe->tuner_priv;
577         *frequency = priv->frequency;
578         return 0;
579 }
580
581 static struct dvb_tuner_ops simple_tuner_ops = {
582         .set_analog_params = simple_set_params,
583         .release        = simple_release,
584         .get_frequency  = simple_get_frequency,
585         .get_status     = simple_get_status,
586 };
587
588 struct dvb_frontend *simple_tuner_attach(struct dvb_frontend *fe,
589                                          struct i2c_adapter *i2c_adap,
590                                          u8 i2c_addr,
591                                          struct simple_tuner_config *cfg)
592 {
593         struct tuner_simple_priv *priv = NULL;
594
595         priv = kzalloc(sizeof(struct tuner_simple_priv), GFP_KERNEL);
596         if (priv == NULL)
597                 return NULL;
598         fe->tuner_priv = priv;
599
600         priv->i2c_props.addr = i2c_addr;
601         priv->i2c_props.adap = i2c_adap;
602         priv->type = cfg->type;
603         priv->tun  = cfg->tun;
604
605         memcpy(&fe->ops.tuner_ops, &simple_tuner_ops, sizeof(struct dvb_tuner_ops));
606
607         tuner_info("type set to %d (%s)\n", cfg->type, cfg->tun->name);
608
609         strlcpy(fe->ops.tuner_ops.info.name, cfg->tun->name, sizeof(fe->ops.tuner_ops.info.name));
610
611         return fe;
612 }
613
614
615 EXPORT_SYMBOL_GPL(simple_tuner_attach);
616
617 MODULE_DESCRIPTION("Simple 4-control-bytes style tuner driver");
618 MODULE_AUTHOR("Ralph Metzler, Gerd Knorr, Gunther Mayer");
619 MODULE_LICENSE("GPL");
620
621 /*
622  * Overrides for Emacs so that we follow Linus's tabbing style.
623  * ---------------------------------------------------------------------------
624  * Local variables:
625  * c-basic-offset: 8
626  * End:
627  */