5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
6 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "pvrusb2-util.h"
25 #include "pvrusb2-demod.h"
26 #include "pvrusb2-hdw-internal.h"
27 #include "pvrusb2-debug.h"
28 #include <linux/videodev2.h>
29 #include <media/tuner.h>
30 #include <media/v4l2-common.h>
33 struct pvr2_demod_handler {
35 struct pvr2_i2c_client *client;
36 struct pvr2_i2c_handler i2c_handler;
41 static void set_config(struct pvr2_demod_handler *ctxt)
43 struct pvr2_hdw *hdw = ctxt->hdw;
46 switch (hdw->tuner_type) {
47 case TUNER_PHILIPS_FM1216ME_MK3:
48 case TUNER_PHILIPS_FM1236_MK3:
49 cfg = TDA9887_PORT1_ACTIVE|TDA9887_PORT2_ACTIVE;
54 pvr2_trace(PVR2_TRACE_CHIPS,"i2c demod set_config(0x%x)",cfg);
55 pvr2_i2c_client_cmd(ctxt->client,TDA9887_SET_CONFIG,&cfg);
56 ctxt->type_update_fl = 0;
60 static int demod_check(struct pvr2_demod_handler *ctxt)
62 struct pvr2_hdw *hdw = ctxt->hdw;
63 if (hdw->tuner_updated) ctxt->type_update_fl = !0;
64 return ctxt->type_update_fl != 0;
68 static void demod_update(struct pvr2_demod_handler *ctxt)
70 if (ctxt->type_update_fl) set_config(ctxt);
74 static void demod_detach(struct pvr2_demod_handler *ctxt)
76 ctxt->client->handler = 0;
81 static unsigned int demod_describe(struct pvr2_demod_handler *ctxt,char *buf,unsigned int cnt)
83 return scnprintf(buf,cnt,"handler: pvrusb2-demod");
87 const static struct pvr2_i2c_handler_functions tuner_funcs = {
88 .detach = (void (*)(void *))demod_detach,
89 .check = (int (*)(void *))demod_check,
90 .update = (void (*)(void *))demod_update,
91 .describe = (unsigned int (*)(void *,char *,unsigned int))demod_describe,
95 int pvr2_i2c_demod_setup(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp)
97 struct pvr2_demod_handler *ctxt;
98 if (cp->handler) return 0;
100 ctxt = kmalloc(sizeof(*ctxt),GFP_KERNEL);
102 memset(ctxt,0,sizeof(*ctxt));
104 ctxt->i2c_handler.func_data = ctxt;
105 ctxt->i2c_handler.func_table = &tuner_funcs;
106 ctxt->type_update_fl = !0;
109 cp->handler = &ctxt->i2c_handler;
110 pvr2_trace(PVR2_TRACE_CHIPS,"i2c 0x%x tda9887 V4L2 handler set up",
119 Stuff for Emacs to see, in order to encourage consistent editing style:
120 *** Local Variables: ***
122 *** fill-column: 70 ***
124 *** c-basic-offset: 8 ***