blob: 49773764383b73eac164ba6e768f34405aa0d20f [file] [log] [blame]
Mike Iselyd8554972006-06-26 20:58:46 -03001/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21
Randy Dunlapab9caf92006-09-28 14:03:26 -030022#include <linux/kernel.h>
Mike Iselyd8554972006-06-26 20:58:46 -030023#include "pvrusb2-i2c-core.h"
24#include "pvrusb2-hdw-internal.h"
25#include "pvrusb2-debug.h"
26#include "pvrusb2-i2c-cmd-v4l2.h"
27#include "pvrusb2-audio.h"
28#include "pvrusb2-tuner.h"
Mike Iselyd8554972006-06-26 20:58:46 -030029#include "pvrusb2-video-v4l.h"
Mike Iselyd8554972006-06-26 20:58:46 -030030#include "pvrusb2-cx2584x-v4l.h"
31#include "pvrusb2-wm8775.h"
Mike Iselyd8554972006-06-26 20:58:46 -030032
33#define trace_i2c(...) pvr2_trace(PVR2_TRACE_I2C,__VA_ARGS__)
34
35#define OP_STANDARD 0
Mike Isely606cf9c2007-01-20 01:56:04 -030036#define OP_AUDIOMODE 1
37#define OP_BCSH 2
38#define OP_VOLUME 3
39#define OP_FREQ 4
40#define OP_AUDIORATE 5
41#define OP_SIZE 6
42#define OP_LOG 7
Mike Iselyd8554972006-06-26 20:58:46 -030043
44static const struct pvr2_i2c_op * const ops[] = {
45 [OP_STANDARD] = &pvr2_i2c_op_v4l2_standard,
Mike Isely606cf9c2007-01-20 01:56:04 -030046 [OP_AUDIOMODE] = &pvr2_i2c_op_v4l2_audiomode,
Mike Iselyd8554972006-06-26 20:58:46 -030047 [OP_BCSH] = &pvr2_i2c_op_v4l2_bcsh,
48 [OP_VOLUME] = &pvr2_i2c_op_v4l2_volume,
49 [OP_FREQ] = &pvr2_i2c_op_v4l2_frequency,
50 [OP_SIZE] = &pvr2_i2c_op_v4l2_size,
51 [OP_LOG] = &pvr2_i2c_op_v4l2_log,
52};
53
54void pvr2_i2c_probe(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp)
55{
56 int id;
57 id = cp->client->driver->id;
58 cp->ctl_mask = ((1 << OP_STANDARD) |
Mike Isely606cf9c2007-01-20 01:56:04 -030059 (1 << OP_AUDIOMODE) |
Mike Iselyd8554972006-06-26 20:58:46 -030060 (1 << OP_BCSH) |
61 (1 << OP_VOLUME) |
62 (1 << OP_FREQ) |
63 (1 << OP_SIZE) |
Mike Iselyf5156b02006-12-27 23:14:54 -030064 (1 << OP_LOG));
Mike Isely18103c572007-01-20 00:09:47 -030065 cp->status_poll = pvr2_v4l2_cmd_status_poll;
Mike Iselyd8554972006-06-26 20:58:46 -030066
67 if (id == I2C_DRIVERID_MSP3400) {
68 if (pvr2_i2c_msp3400_setup(hdw,cp)) {
69 return;
70 }
71 }
72 if (id == I2C_DRIVERID_TUNER) {
73 if (pvr2_i2c_tuner_setup(hdw,cp)) {
74 return;
75 }
76 }
Mike Iselyd8554972006-06-26 20:58:46 -030077 if (id == I2C_DRIVERID_CX25840) {
78 if (pvr2_i2c_cx2584x_v4l_setup(hdw,cp)) {
79 return;
80 }
81 }
82 if (id == I2C_DRIVERID_WM8775) {
83 if (pvr2_i2c_wm8775_setup(hdw,cp)) {
84 return;
85 }
86 }
Mike Iselyd8554972006-06-26 20:58:46 -030087 if (id == I2C_DRIVERID_SAA711X) {
88 if (pvr2_i2c_decoder_v4l_setup(hdw,cp)) {
89 return;
90 }
91 }
Mike Iselyd8554972006-06-26 20:58:46 -030092}
93
94
95const struct pvr2_i2c_op *pvr2_i2c_get_op(unsigned int idx)
96{
Randy Dunlapab9caf92006-09-28 14:03:26 -030097 if (idx >= ARRAY_SIZE(ops))
98 return NULL;
Mike Iselyd8554972006-06-26 20:58:46 -030099 return ops[idx];
100}
101
102
103/*
104 Stuff for Emacs to see, in order to encourage consistent editing style:
105 *** Local Variables: ***
106 *** mode: c ***
107 *** fill-column: 75 ***
108 *** tab-width: 8 ***
109 *** c-basic-offset: 8 ***
110 *** End: ***
111 */