Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 1 | /* |
| 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 Dunlap | ab9caf9 | 2006-09-28 14:03:26 -0300 | [diff] [blame] | 22 | #include <linux/kernel.h> |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 23 | #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 Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 29 | #include "pvrusb2-video-v4l.h" |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 30 | #include "pvrusb2-cx2584x-v4l.h" |
| 31 | #include "pvrusb2-wm8775.h" |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 32 | |
| 33 | #define trace_i2c(...) pvr2_trace(PVR2_TRACE_I2C,__VA_ARGS__) |
| 34 | |
| 35 | #define OP_STANDARD 0 |
| 36 | #define OP_BCSH 1 |
| 37 | #define OP_VOLUME 2 |
| 38 | #define OP_FREQ 3 |
| 39 | #define OP_AUDIORATE 4 |
| 40 | #define OP_SIZE 5 |
| 41 | #define OP_LOG 6 |
| 42 | |
| 43 | static const struct pvr2_i2c_op * const ops[] = { |
| 44 | [OP_STANDARD] = &pvr2_i2c_op_v4l2_standard, |
| 45 | [OP_BCSH] = &pvr2_i2c_op_v4l2_bcsh, |
| 46 | [OP_VOLUME] = &pvr2_i2c_op_v4l2_volume, |
| 47 | [OP_FREQ] = &pvr2_i2c_op_v4l2_frequency, |
| 48 | [OP_SIZE] = &pvr2_i2c_op_v4l2_size, |
| 49 | [OP_LOG] = &pvr2_i2c_op_v4l2_log, |
| 50 | }; |
| 51 | |
| 52 | void pvr2_i2c_probe(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp) |
| 53 | { |
| 54 | int id; |
| 55 | id = cp->client->driver->id; |
| 56 | cp->ctl_mask = ((1 << OP_STANDARD) | |
| 57 | (1 << OP_BCSH) | |
| 58 | (1 << OP_VOLUME) | |
| 59 | (1 << OP_FREQ) | |
| 60 | (1 << OP_SIZE) | |
| 61 | (1 << OP_LOG)); |
| 62 | |
| 63 | if (id == I2C_DRIVERID_MSP3400) { |
| 64 | if (pvr2_i2c_msp3400_setup(hdw,cp)) { |
| 65 | return; |
| 66 | } |
| 67 | } |
| 68 | if (id == I2C_DRIVERID_TUNER) { |
| 69 | if (pvr2_i2c_tuner_setup(hdw,cp)) { |
| 70 | return; |
| 71 | } |
| 72 | } |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 73 | if (id == I2C_DRIVERID_CX25840) { |
| 74 | if (pvr2_i2c_cx2584x_v4l_setup(hdw,cp)) { |
| 75 | return; |
| 76 | } |
| 77 | } |
| 78 | if (id == I2C_DRIVERID_WM8775) { |
| 79 | if (pvr2_i2c_wm8775_setup(hdw,cp)) { |
| 80 | return; |
| 81 | } |
| 82 | } |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 83 | if (id == I2C_DRIVERID_SAA711X) { |
| 84 | if (pvr2_i2c_decoder_v4l_setup(hdw,cp)) { |
| 85 | return; |
| 86 | } |
| 87 | } |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | |
| 91 | const struct pvr2_i2c_op *pvr2_i2c_get_op(unsigned int idx) |
| 92 | { |
Randy Dunlap | ab9caf9 | 2006-09-28 14:03:26 -0300 | [diff] [blame] | 93 | if (idx >= ARRAY_SIZE(ops)) |
| 94 | return NULL; |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 95 | return ops[idx]; |
| 96 | } |
| 97 | |
| 98 | |
| 99 | /* |
| 100 | Stuff for Emacs to see, in order to encourage consistent editing style: |
| 101 | *** Local Variables: *** |
| 102 | *** mode: c *** |
| 103 | *** fill-column: 75 *** |
| 104 | *** tab-width: 8 *** |
| 105 | *** c-basic-offset: 8 *** |
| 106 | *** End: *** |
| 107 | */ |