V4L/DVB (6096): ivtv: fix V4L2_ENC_CMD_STOP_AT_GOP_END support
[safe/jmp/linux-2.6] / drivers / media / video / tda9887.c
1 #include <linux/module.h>
2 #include <linux/kernel.h>
3 #include <linux/i2c.h>
4 #include <linux/types.h>
5 #include <linux/init.h>
6 #include <linux/errno.h>
7 #include <linux/slab.h>
8 #include <linux/delay.h>
9 #include <linux/videodev.h>
10 #include <media/v4l2-common.h>
11 #include <media/tuner.h>
12 #include "tuner-driver.h"
13
14
15 /* Chips:
16    TDA9885 (PAL, NTSC)
17    TDA9886 (PAL, SECAM, NTSC)
18    TDA9887 (PAL, SECAM, NTSC, FM Radio)
19
20    Used as part of several tuners
21 */
22
23 #define tda9887_info(fmt, arg...) do {\
24         printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.name, \
25                         i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0)
26 #define tda9887_dbg(fmt, arg...) do {\
27         if (tuner_debug) \
28                 printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.name, \
29                         i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0)
30
31 struct tda9887_priv {
32         unsigned char      data[4];
33 };
34
35 /* ---------------------------------------------------------------------- */
36
37 #define UNSET       (-1U)
38
39 struct tvnorm {
40         v4l2_std_id       std;
41         char              *name;
42         unsigned char     b;
43         unsigned char     c;
44         unsigned char     e;
45 };
46
47 /* ---------------------------------------------------------------------- */
48
49 //
50 // TDA defines
51 //
52
53 //// first reg (b)
54 #define cVideoTrapBypassOFF     0x00    // bit b0
55 #define cVideoTrapBypassON      0x01    // bit b0
56
57 #define cAutoMuteFmInactive     0x00    // bit b1
58 #define cAutoMuteFmActive       0x02    // bit b1
59
60 #define cIntercarrier           0x00    // bit b2
61 #define cQSS                    0x04    // bit b2
62
63 #define cPositiveAmTV           0x00    // bit b3:4
64 #define cFmRadio                0x08    // bit b3:4
65 #define cNegativeFmTV           0x10    // bit b3:4
66
67
68 #define cForcedMuteAudioON      0x20    // bit b5
69 #define cForcedMuteAudioOFF     0x00    // bit b5
70
71 #define cOutputPort1Active      0x00    // bit b6
72 #define cOutputPort1Inactive    0x40    // bit b6
73
74 #define cOutputPort2Active      0x00    // bit b7
75 #define cOutputPort2Inactive    0x80    // bit b7
76
77
78 //// second reg (c)
79 #define cDeemphasisOFF          0x00    // bit c5
80 #define cDeemphasisON           0x20    // bit c5
81
82 #define cDeemphasis75           0x00    // bit c6
83 #define cDeemphasis50           0x40    // bit c6
84
85 #define cAudioGain0             0x00    // bit c7
86 #define cAudioGain6             0x80    // bit c7
87
88 #define cTopMask                0x1f    // bit c0:4
89 #define cTopDefault             0x10    // bit c0:4
90
91 //// third reg (e)
92 #define cAudioIF_4_5             0x00    // bit e0:1
93 #define cAudioIF_5_5             0x01    // bit e0:1
94 #define cAudioIF_6_0             0x02    // bit e0:1
95 #define cAudioIF_6_5             0x03    // bit e0:1
96
97
98 #define cVideoIFMask            0x1c    // bit e2:4
99 /* Video IF selection in TV Mode (bit B3=0) */
100 #define cVideoIF_58_75           0x00    // bit e2:4
101 #define cVideoIF_45_75           0x04    // bit e2:4
102 #define cVideoIF_38_90           0x08    // bit e2:4
103 #define cVideoIF_38_00           0x0C    // bit e2:4
104 #define cVideoIF_33_90           0x10    // bit e2:4
105 #define cVideoIF_33_40           0x14    // bit e2:4
106 #define cRadioIF_45_75           0x18    // bit e2:4
107 #define cRadioIF_38_90           0x1C    // bit e2:4
108
109 /* IF1 selection in Radio Mode (bit B3=1) */
110 #define cRadioIF_33_30          0x00    // bit e2,4 (also 0x10,0x14)
111 #define cRadioIF_41_30          0x04    // bit e2,4
112
113 /* Output of AFC pin in radio mode when bit E7=1 */
114 #define cRadioAGC_SIF           0x00    // bit e3
115 #define cRadioAGC_FM            0x08    // bit e3
116
117 #define cTunerGainNormal         0x00    // bit e5
118 #define cTunerGainLow            0x20    // bit e5
119
120 #define cGating_18               0x00    // bit e6
121 #define cGating_36               0x40    // bit e6
122
123 #define cAgcOutON                0x80    // bit e7
124 #define cAgcOutOFF               0x00    // bit e7
125
126 /* ---------------------------------------------------------------------- */
127
128 static struct tvnorm tvnorms[] = {
129         {
130                 .std   = V4L2_STD_PAL_BG | V4L2_STD_PAL_H | V4L2_STD_PAL_N,
131                 .name  = "PAL-BGHN",
132                 .b     = ( cNegativeFmTV  |
133                            cQSS           ),
134                 .c     = ( cDeemphasisON  |
135                            cDeemphasis50  |
136                            cTopDefault),
137                 .e     = ( cGating_36     |
138                            cAudioIF_5_5   |
139                            cVideoIF_38_90 ),
140         },{
141                 .std   = V4L2_STD_PAL_I,
142                 .name  = "PAL-I",
143                 .b     = ( cNegativeFmTV  |
144                            cQSS           ),
145                 .c     = ( cDeemphasisON  |
146                            cDeemphasis50  |
147                            cTopDefault),
148                 .e     = ( cGating_36     |
149                            cAudioIF_6_0   |
150                            cVideoIF_38_90 ),
151         },{
152                 .std   = V4L2_STD_PAL_DK,
153                 .name  = "PAL-DK",
154                 .b     = ( cNegativeFmTV  |
155                            cQSS           ),
156                 .c     = ( cDeemphasisON  |
157                            cDeemphasis50  |
158                            cTopDefault),
159                 .e     = ( cGating_36     |
160                            cAudioIF_6_5   |
161                            cVideoIF_38_90 ),
162         },{
163                 .std   = V4L2_STD_PAL_M | V4L2_STD_PAL_Nc,
164                 .name  = "PAL-M/Nc",
165                 .b     = ( cNegativeFmTV  |
166                            cQSS           ),
167                 .c     = ( cDeemphasisON  |
168                            cDeemphasis75  |
169                            cTopDefault),
170                 .e     = ( cGating_36     |
171                            cAudioIF_4_5   |
172                            cVideoIF_45_75 ),
173         },{
174                 .std   = V4L2_STD_SECAM_B | V4L2_STD_SECAM_G | V4L2_STD_SECAM_H,
175                 .name  = "SECAM-BGH",
176                 .b     = ( cPositiveAmTV  |
177                            cQSS           ),
178                 .c     = ( cTopDefault),
179                 .e     = ( cGating_36     |
180                            cAudioIF_5_5   |
181                            cVideoIF_38_90 ),
182         },{
183                 .std   = V4L2_STD_SECAM_L,
184                 .name  = "SECAM-L",
185                 .b     = ( cPositiveAmTV  |
186                            cQSS           ),
187                 .c     = ( cTopDefault),
188                 .e     = ( cGating_36     |
189                            cAudioIF_6_5   |
190                            cVideoIF_38_90 ),
191         },{
192                 .std   = V4L2_STD_SECAM_LC,
193                 .name  = "SECAM-L'",
194                 .b     = ( cOutputPort2Inactive |
195                            cPositiveAmTV  |
196                            cQSS           ),
197                 .c     = ( cTopDefault),
198                 .e     = ( cGating_36     |
199                            cAudioIF_6_5   |
200                            cVideoIF_33_90 ),
201         },{
202                 .std   = V4L2_STD_SECAM_DK,
203                 .name  = "SECAM-DK",
204                 .b     = ( cNegativeFmTV  |
205                            cQSS           ),
206                 .c     = ( cDeemphasisON  |
207                            cDeemphasis50  |
208                            cTopDefault),
209                 .e     = ( cGating_36     |
210                            cAudioIF_6_5   |
211                            cVideoIF_38_90 ),
212         },{
213                 .std   = V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_KR,
214                 .name  = "NTSC-M",
215                 .b     = ( cNegativeFmTV  |
216                            cQSS           ),
217                 .c     = ( cDeemphasisON  |
218                            cDeemphasis75  |
219                            cTopDefault),
220                 .e     = ( cGating_36     |
221                            cAudioIF_4_5   |
222                            cVideoIF_45_75 ),
223         },{
224                 .std   = V4L2_STD_NTSC_M_JP,
225                 .name  = "NTSC-M-JP",
226                 .b     = ( cNegativeFmTV  |
227                            cQSS           ),
228                 .c     = ( cDeemphasisON  |
229                            cDeemphasis50  |
230                            cTopDefault),
231                 .e     = ( cGating_36     |
232                            cAudioIF_4_5   |
233                            cVideoIF_58_75 ),
234         }
235 };
236
237 static struct tvnorm radio_stereo = {
238         .name = "Radio Stereo",
239         .b    = ( cFmRadio       |
240                   cQSS           ),
241         .c    = ( cDeemphasisOFF |
242                   cAudioGain6    |
243                   cTopDefault),
244         .e    = ( cTunerGainLow  |
245                   cAudioIF_5_5   |
246                   cRadioIF_38_90 ),
247 };
248
249 static struct tvnorm radio_mono = {
250         .name = "Radio Mono",
251         .b    = ( cFmRadio       |
252                   cQSS           ),
253         .c    = ( cDeemphasisON  |
254                   cDeemphasis75  |
255                   cTopDefault),
256         .e    = ( cTunerGainLow  |
257                   cAudioIF_5_5   |
258                   cRadioIF_38_90 ),
259 };
260
261 /* ---------------------------------------------------------------------- */
262
263 static void dump_read_message(struct tuner *t, unsigned char *buf)
264 {
265         static char *afc[16] = {
266                 "- 12.5 kHz",
267                 "- 37.5 kHz",
268                 "- 62.5 kHz",
269                 "- 87.5 kHz",
270                 "-112.5 kHz",
271                 "-137.5 kHz",
272                 "-162.5 kHz",
273                 "-187.5 kHz [min]",
274                 "+187.5 kHz [max]",
275                 "+162.5 kHz",
276                 "+137.5 kHz",
277                 "+112.5 kHz",
278                 "+ 87.5 kHz",
279                 "+ 62.5 kHz",
280                 "+ 37.5 kHz",
281                 "+ 12.5 kHz",
282         };
283         tda9887_info("read: 0x%2x\n", buf[0]);
284         tda9887_info("  after power on : %s\n", (buf[0] & 0x01) ? "yes" : "no");
285         tda9887_info("  afc            : %s\n", afc[(buf[0] >> 1) & 0x0f]);
286         tda9887_info("  fmif level     : %s\n", (buf[0] & 0x20) ? "high" : "low");
287         tda9887_info("  afc window     : %s\n", (buf[0] & 0x40) ? "in" : "out");
288         tda9887_info("  vfi level      : %s\n", (buf[0] & 0x80) ? "high" : "low");
289 }
290
291 static void dump_write_message(struct tuner *t, unsigned char *buf)
292 {
293         static char *sound[4] = {
294                 "AM/TV",
295                 "FM/radio",
296                 "FM/TV",
297                 "FM/radio"
298         };
299         static char *adjust[32] = {
300                 "-16", "-15", "-14", "-13", "-12", "-11", "-10", "-9",
301                 "-8",  "-7",  "-6",  "-5",  "-4",  "-3",  "-2",  "-1",
302                 "0",   "+1",  "+2",  "+3",  "+4",  "+5",  "+6",  "+7",
303                 "+8",  "+9",  "+10", "+11", "+12", "+13", "+14", "+15"
304         };
305         static char *deemph[4] = {
306                 "no", "no", "75", "50"
307         };
308         static char *carrier[4] = {
309                 "4.5 MHz",
310                 "5.5 MHz",
311                 "6.0 MHz",
312                 "6.5 MHz / AM"
313         };
314         static char *vif[8] = {
315                 "58.75 MHz",
316                 "45.75 MHz",
317                 "38.9 MHz",
318                 "38.0 MHz",
319                 "33.9 MHz",
320                 "33.4 MHz",
321                 "45.75 MHz + pin13",
322                 "38.9 MHz + pin13",
323         };
324         static char *rif[4] = {
325                 "44 MHz",
326                 "52 MHz",
327                 "52 MHz",
328                 "44 MHz",
329         };
330
331         tda9887_info("write: byte B 0x%02x\n",buf[1]);
332         tda9887_info("  B0   video mode      : %s\n",
333                (buf[1] & 0x01) ? "video trap" : "sound trap");
334         tda9887_info("  B1   auto mute fm    : %s\n",
335                (buf[1] & 0x02) ? "yes" : "no");
336         tda9887_info("  B2   carrier mode    : %s\n",
337                (buf[1] & 0x04) ? "QSS" : "Intercarrier");
338         tda9887_info("  B3-4 tv sound/radio  : %s\n",
339                sound[(buf[1] & 0x18) >> 3]);
340         tda9887_info("  B5   force mute audio: %s\n",
341                (buf[1] & 0x20) ? "yes" : "no");
342         tda9887_info("  B6   output port 1   : %s\n",
343                (buf[1] & 0x40) ? "high (inactive)" : "low (active)");
344         tda9887_info("  B7   output port 2   : %s\n",
345                (buf[1] & 0x80) ? "high (inactive)" : "low (active)");
346
347         tda9887_info("write: byte C 0x%02x\n",buf[2]);
348         tda9887_info("  C0-4 top adjustment  : %s dB\n", adjust[buf[2] & 0x1f]);
349         tda9887_info("  C5-6 de-emphasis     : %s\n", deemph[(buf[2] & 0x60) >> 5]);
350         tda9887_info("  C7   audio gain      : %s\n",
351                (buf[2] & 0x80) ? "-6" : "0");
352
353         tda9887_info("write: byte E 0x%02x\n",buf[3]);
354         tda9887_info("  E0-1 sound carrier   : %s\n",
355                carrier[(buf[3] & 0x03)]);
356         tda9887_info("  E6   l pll gating   : %s\n",
357                (buf[3] & 0x40) ? "36" : "13");
358
359         if (buf[1] & 0x08) {
360                 /* radio */
361                 tda9887_info("  E2-4 video if        : %s\n",
362                        rif[(buf[3] & 0x0c) >> 2]);
363                 tda9887_info("  E7   vif agc output  : %s\n",
364                        (buf[3] & 0x80)
365                        ? ((buf[3] & 0x10) ? "fm-agc radio" : "sif-agc radio")
366                        : "fm radio carrier afc");
367         } else {
368                 /* video */
369                 tda9887_info("  E2-4 video if        : %s\n",
370                        vif[(buf[3] & 0x1c) >> 2]);
371                 tda9887_info("  E5   tuner gain      : %s\n",
372                        (buf[3] & 0x80)
373                        ? ((buf[3] & 0x20) ? "external" : "normal")
374                        : ((buf[3] & 0x20) ? "minimum"  : "normal"));
375                 tda9887_info("  E7   vif agc output  : %s\n",
376                        (buf[3] & 0x80)
377                        ? ((buf[3] & 0x20)
378                           ? "pin3 port, pin22 vif agc out"
379                           : "pin22 port, pin3 vif acg ext in")
380                        : "pin3+pin22 port");
381         }
382         tda9887_info("--\n");
383 }
384
385 /* ---------------------------------------------------------------------- */
386
387 static int tda9887_set_tvnorm(struct tuner *t, char *buf)
388 {
389         struct tvnorm *norm = NULL;
390         int i;
391
392         if (t->mode == V4L2_TUNER_RADIO) {
393                 if (t->audmode == V4L2_TUNER_MODE_MONO)
394                         norm = &radio_mono;
395                 else
396                         norm = &radio_stereo;
397         } else {
398                 for (i = 0; i < ARRAY_SIZE(tvnorms); i++) {
399                         if (tvnorms[i].std & t->std) {
400                                 norm = tvnorms+i;
401                                 break;
402                         }
403                 }
404         }
405         if (NULL == norm) {
406                 tda9887_dbg("Unsupported tvnorm entry - audio muted\n");
407                 return -1;
408         }
409
410         tda9887_dbg("configure for: %s\n",norm->name);
411         buf[1] = norm->b;
412         buf[2] = norm->c;
413         buf[3] = norm->e;
414         return 0;
415 }
416
417 static unsigned int port1  = UNSET;
418 static unsigned int port2  = UNSET;
419 static unsigned int qss    = UNSET;
420 static unsigned int adjust = UNSET;
421
422 module_param(port1, int, 0644);
423 module_param(port2, int, 0644);
424 module_param(qss, int, 0644);
425 module_param(adjust, int, 0644);
426
427 static int tda9887_set_insmod(struct tuner *t, char *buf)
428 {
429         if (UNSET != port1) {
430                 if (port1)
431                         buf[1] |= cOutputPort1Inactive;
432                 else
433                         buf[1] &= ~cOutputPort1Inactive;
434         }
435         if (UNSET != port2) {
436                 if (port2)
437                         buf[1] |= cOutputPort2Inactive;
438                 else
439                         buf[1] &= ~cOutputPort2Inactive;
440         }
441
442         if (UNSET != qss) {
443                 if (qss)
444                         buf[1] |= cQSS;
445                 else
446                         buf[1] &= ~cQSS;
447         }
448
449         if (adjust >= 0x00 && adjust < 0x20) {
450                 buf[2] &= ~cTopMask;
451                 buf[2] |= adjust;
452         }
453         return 0;
454 }
455
456 static int tda9887_set_config(struct tuner *t, char *buf)
457 {
458         if (t->tda9887_config & TDA9887_PORT1_ACTIVE)
459                 buf[1] &= ~cOutputPort1Inactive;
460         if (t->tda9887_config & TDA9887_PORT1_INACTIVE)
461                 buf[1] |= cOutputPort1Inactive;
462         if (t->tda9887_config & TDA9887_PORT2_ACTIVE)
463                 buf[1] &= ~cOutputPort2Inactive;
464         if (t->tda9887_config & TDA9887_PORT2_INACTIVE)
465                 buf[1] |= cOutputPort2Inactive;
466
467         if (t->tda9887_config & TDA9887_QSS)
468                 buf[1] |= cQSS;
469         if (t->tda9887_config & TDA9887_INTERCARRIER)
470                 buf[1] &= ~cQSS;
471
472         if (t->tda9887_config & TDA9887_AUTOMUTE)
473                 buf[1] |= cAutoMuteFmActive;
474         if (t->tda9887_config & TDA9887_DEEMPHASIS_MASK) {
475                 buf[2] &= ~0x60;
476                 switch (t->tda9887_config & TDA9887_DEEMPHASIS_MASK) {
477                 case TDA9887_DEEMPHASIS_NONE:
478                         buf[2] |= cDeemphasisOFF;
479                         break;
480                 case TDA9887_DEEMPHASIS_50:
481                         buf[2] |= cDeemphasisON | cDeemphasis50;
482                         break;
483                 case TDA9887_DEEMPHASIS_75:
484                         buf[2] |= cDeemphasisON | cDeemphasis75;
485                         break;
486                 }
487         }
488         if (t->tda9887_config & TDA9887_TOP_SET) {
489                 buf[2] &= ~cTopMask;
490                 buf[2] |= (t->tda9887_config >> 8) & cTopMask;
491         }
492         if ((t->tda9887_config & TDA9887_INTERCARRIER_NTSC) && (t->std & V4L2_STD_NTSC))
493                 buf[1] &= ~cQSS;
494         if (t->tda9887_config & TDA9887_GATING_18)
495                 buf[3] &= ~cGating_36;
496
497         if (t->mode == V4L2_TUNER_RADIO) {
498                 if (t->tda9887_config & TDA9887_RIF_41_3) {
499                         buf[3] &= ~cVideoIFMask;
500                         buf[3] |= cRadioIF_41_30;
501                 }
502                 if (t->tda9887_config & TDA9887_GAIN_NORMAL)
503                         buf[3] &= ~cTunerGainLow;
504         }
505
506         return 0;
507 }
508
509 /* ---------------------------------------------------------------------- */
510
511 static int tda9887_status(struct tuner *t)
512 {
513         unsigned char buf[1];
514         int rc;
515
516         memset(buf,0,sizeof(buf));
517         if (1 != (rc = i2c_master_recv(&t->i2c,buf,1)))
518                 tda9887_info("i2c i/o error: rc == %d (should be 1)\n",rc);
519         dump_read_message(t, buf);
520         return 0;
521 }
522
523 static void tda9887_configure(struct i2c_client *client)
524 {
525         struct tuner *t = i2c_get_clientdata(client);
526         struct tda9887_priv *priv = t->priv;
527         int rc;
528
529         memset(priv->data,0,sizeof(priv->data));
530         tda9887_set_tvnorm(t,priv->data);
531
532         /* A note on the port settings:
533            These settings tend to depend on the specifics of the board.
534            By default they are set to inactive (bit value 1) by this driver,
535            overwriting any changes made by the tvnorm. This means that it
536            is the responsibility of the module using the tda9887 to set
537            these values in case of changes in the tvnorm.
538            In many cases port 2 should be made active (0) when selecting
539            SECAM-L, and port 2 should remain inactive (1) for SECAM-L'.
540
541            For the other standards the tda9887 application note says that
542            the ports should be set to active (0), but, again, that may
543            differ depending on the precise hardware configuration.
544          */
545         priv->data[1] |= cOutputPort1Inactive;
546         priv->data[1] |= cOutputPort2Inactive;
547
548         tda9887_set_config(t,priv->data);
549         tda9887_set_insmod(t,priv->data);
550
551         if (t->mode == T_STANDBY) {
552                 priv->data[1] |= cForcedMuteAudioON;
553         }
554
555         tda9887_dbg("writing: b=0x%02x c=0x%02x e=0x%02x\n",
556                 priv->data[1],priv->data[2],priv->data[3]);
557         if (tuner_debug > 1)
558                 dump_write_message(t, priv->data);
559
560         if (4 != (rc = i2c_master_send(&t->i2c,priv->data,4)))
561                 tda9887_info("i2c i/o error: rc == %d (should be 4)\n",rc);
562
563         if (tuner_debug > 2) {
564                 msleep_interruptible(1000);
565                 tda9887_status(t);
566         }
567 }
568
569 /* ---------------------------------------------------------------------- */
570
571 static void tda9887_tuner_status(struct i2c_client *client)
572 {
573         struct tuner *t = i2c_get_clientdata(client);
574         struct tda9887_priv *priv = t->priv;
575         tda9887_info("Data bytes: b=0x%02x c=0x%02x e=0x%02x\n", priv->data[1], priv->data[2], priv->data[3]);
576 }
577
578 static int tda9887_get_afc(struct i2c_client *client)
579 {
580         struct tuner *t = i2c_get_clientdata(client);
581         static int AFC_BITS_2_kHz[] = {
582                 -12500,  -37500,  -62500,  -97500,
583                 -112500, -137500, -162500, -187500,
584                 187500,  162500,  137500,  112500,
585                 97500 ,  62500,   37500 ,  12500
586         };
587         int afc=0;
588         __u8 reg = 0;
589
590         if (1 == i2c_master_recv(&t->i2c,&reg,1))
591                 afc = AFC_BITS_2_kHz[(reg>>1)&0x0f];
592
593         return afc;
594 }
595
596 static void tda9887_standby(struct i2c_client *client)
597 {
598         tda9887_configure(client);
599 }
600
601 static void tda9887_set_freq(struct i2c_client *client, unsigned int freq)
602 {
603         tda9887_configure(client);
604 }
605
606 static void tda9887_release(struct i2c_client *c)
607 {
608         struct tuner *t = i2c_get_clientdata(c);
609
610         kfree(t->priv);
611         t->priv = NULL;
612 }
613
614 static struct tuner_operations tda9887_tuner_ops = {
615         .set_tv_freq    = tda9887_set_freq,
616         .set_radio_freq = tda9887_set_freq,
617         .standby        = tda9887_standby,
618         .tuner_status   = tda9887_tuner_status,
619         .get_afc        = tda9887_get_afc,
620         .release        = tda9887_release,
621 };
622
623 int tda9887_tuner_init(struct i2c_client *c)
624 {
625         struct tda9887_priv *priv = NULL;
626         struct tuner *t = i2c_get_clientdata(c);
627
628         priv = kzalloc(sizeof(struct tda9887_priv), GFP_KERNEL);
629         if (priv == NULL)
630                 return -ENOMEM;
631         t->priv = priv;
632
633         strlcpy(c->name, "tda9887", sizeof(c->name));
634
635         tda9887_info("tda988[5/6/7] found @ 0x%x (%s)\n", t->i2c.addr,
636                                                 t->i2c.driver->driver.name);
637
638         memcpy(&t->ops, &tda9887_tuner_ops, sizeof(struct tuner_operations));
639
640         return 0;
641 }
642
643 /*
644  * Overrides for Emacs so that we follow Linus's tabbing style.
645  * ---------------------------------------------------------------------------
646  * Local variables:
647  * c-basic-offset: 8
648  * End:
649  */