blob: 94a47718e88eb0dcd275f9c080d23440dfbdad85 [file] [log] [blame]
Mike Iselyd8554972006-06-26 20:58:46 -03001/*
2 *
Mike Iselyd8554972006-06-26 20:58:46 -03003 *
4 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */
20
Randy Dunlapab9caf92006-09-28 14:03:26 -030021#include <linux/kernel.h>
Mike Iselyd8554972006-06-26 20:58:46 -030022#include "pvrusb2-i2c-core.h"
23#include "pvrusb2-hdw-internal.h"
24#include "pvrusb2-debug.h"
25#include "pvrusb2-i2c-cmd-v4l2.h"
26#include "pvrusb2-audio.h"
27#include "pvrusb2-tuner.h"
Mike Iselyd8554972006-06-26 20:58:46 -030028#include "pvrusb2-video-v4l.h"
Mike Iselyd8554972006-06-26 20:58:46 -030029#include "pvrusb2-cx2584x-v4l.h"
30#include "pvrusb2-wm8775.h"
Mike Iselyd8554972006-06-26 20:58:46 -030031
32#define trace_i2c(...) pvr2_trace(PVR2_TRACE_I2C,__VA_ARGS__)
33
34#define OP_STANDARD 0
Mike Isely606cf9c2007-01-20 01:56:04 -030035#define OP_AUDIOMODE 1
36#define OP_BCSH 2
37#define OP_VOLUME 3
38#define OP_FREQ 4
39#define OP_AUDIORATE 5
vdb128@picaros.orge784bfb2008-08-30 18:26:39 -030040#define OP_CROP 6
41#define OP_SIZE 7
42#define OP_LOG 8
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,
vdb128@picaros.orge784bfb2008-08-30 18:26:39 -030050 [OP_CROP] = &pvr2_i2c_op_v4l2_crop,
Mike Iselyd8554972006-06-26 20:58:46 -030051 [OP_SIZE] = &pvr2_i2c_op_v4l2_size,
52 [OP_LOG] = &pvr2_i2c_op_v4l2_log,
53};
54
55void pvr2_i2c_probe(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp)
56{
57 int id;
58 id = cp->client->driver->id;
59 cp->ctl_mask = ((1 << OP_STANDARD) |
Mike Isely606cf9c2007-01-20 01:56:04 -030060 (1 << OP_AUDIOMODE) |
Mike Iselyd8554972006-06-26 20:58:46 -030061 (1 << OP_BCSH) |
62 (1 << OP_VOLUME) |
63 (1 << OP_FREQ) |
vdb128@picaros.orge784bfb2008-08-30 18:26:39 -030064 (1 << OP_CROP) |
Mike Iselyd8554972006-06-26 20:58:46 -030065 (1 << OP_SIZE) |
Mike Iselyf5156b02006-12-27 23:14:54 -030066 (1 << OP_LOG));
Mike Isely18103c52007-01-20 00:09:47 -030067 cp->status_poll = pvr2_v4l2_cmd_status_poll;
Mike Iselyd8554972006-06-26 20:58:46 -030068
69 if (id == I2C_DRIVERID_MSP3400) {
70 if (pvr2_i2c_msp3400_setup(hdw,cp)) {
71 return;
72 }
73 }
74 if (id == I2C_DRIVERID_TUNER) {
75 if (pvr2_i2c_tuner_setup(hdw,cp)) {
76 return;
77 }
78 }
Mike Iselyd8554972006-06-26 20:58:46 -030079 if (id == I2C_DRIVERID_CX25840) {
80 if (pvr2_i2c_cx2584x_v4l_setup(hdw,cp)) {
81 return;
82 }
83 }
84 if (id == I2C_DRIVERID_WM8775) {
85 if (pvr2_i2c_wm8775_setup(hdw,cp)) {
86 return;
87 }
88 }
Mike Iselyd8554972006-06-26 20:58:46 -030089 if (id == I2C_DRIVERID_SAA711X) {
90 if (pvr2_i2c_decoder_v4l_setup(hdw,cp)) {
91 return;
92 }
93 }
Mike Iselyd8554972006-06-26 20:58:46 -030094}
95
96
97const struct pvr2_i2c_op *pvr2_i2c_get_op(unsigned int idx)
98{
Randy Dunlapab9caf92006-09-28 14:03:26 -030099 if (idx >= ARRAY_SIZE(ops))
100 return NULL;
Mike Iselyd8554972006-06-26 20:58:46 -0300101 return ops[idx];
102}
103
104
105/*
106 Stuff for Emacs to see, in order to encourage consistent editing style:
107 *** Local Variables: ***
108 *** mode: c ***
109 *** fill-column: 75 ***
110 *** tab-width: 8 ***
111 *** c-basic-offset: 8 ***
112 *** End: ***
113 */