Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 1 | /* |
| 2 | * wm8739 |
| 3 | * |
| 4 | * Copyright (C) 2005 T. Adachi <tadachi@tadachi-net.com> |
| 5 | * |
| 6 | * Copyright (C) 2005 Hans Verkuil <hverkuil@xs4all.nl> |
| 7 | * - Cleanup |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 22 | */ |
| 23 | |
| 24 | #include <linux/module.h> |
| 25 | #include <linux/types.h> |
| 26 | #include <linux/ioctl.h> |
| 27 | #include <asm/uaccess.h> |
| 28 | #include <linux/i2c.h> |
| 29 | #include <linux/i2c-id.h> |
Hans Verkuil | 33b687c | 2008-07-25 05:32:50 -0300 | [diff] [blame] | 30 | #include <linux/videodev2.h> |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 31 | #include <media/v4l2-device.h> |
Hans Verkuil | 74cab31 | 2007-04-27 12:31:26 -0300 | [diff] [blame] | 32 | #include <media/v4l2-chip-ident.h> |
Hans Verkuil | f69d419 | 2007-12-12 07:24:27 -0300 | [diff] [blame] | 33 | #include <media/v4l2-i2c-drv.h> |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 34 | |
| 35 | MODULE_DESCRIPTION("wm8739 driver"); |
| 36 | MODULE_AUTHOR("T. Adachi, Hans Verkuil"); |
| 37 | MODULE_LICENSE("GPL"); |
| 38 | |
Hans Verkuil | 099b8e7 | 2007-11-01 07:45:54 -0300 | [diff] [blame] | 39 | static int debug; |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 40 | |
| 41 | module_param(debug, int, 0644); |
| 42 | |
| 43 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); |
| 44 | |
| 45 | |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 46 | /* ------------------------------------------------------------------------ */ |
| 47 | |
| 48 | enum { |
| 49 | R0 = 0, R1, |
| 50 | R5 = 5, R6, R7, R8, R9, R15 = 15, |
| 51 | TOT_REGS |
| 52 | }; |
| 53 | |
| 54 | struct wm8739_state { |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 55 | struct v4l2_subdev sd; |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 56 | u32 clock_freq; |
| 57 | u8 muted; |
| 58 | u16 volume; |
| 59 | u16 balance; |
| 60 | u8 vol_l; /* +12dB to -34.5dB 1.5dB step (5bit) def:0dB */ |
| 61 | u8 vol_r; /* +12dB to -34.5dB 1.5dB step (5bit) def:0dB */ |
| 62 | }; |
| 63 | |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 64 | static inline struct wm8739_state *to_state(struct v4l2_subdev *sd) |
| 65 | { |
| 66 | return container_of(sd, struct wm8739_state, sd); |
| 67 | } |
| 68 | |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 69 | /* ------------------------------------------------------------------------ */ |
| 70 | |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 71 | static int wm8739_write(struct v4l2_subdev *sd, int reg, u16 val) |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 72 | { |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 73 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 74 | int i; |
| 75 | |
| 76 | if (reg < 0 || reg >= TOT_REGS) { |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 77 | v4l2_err(sd, "Invalid register R%d\n", reg); |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 78 | return -1; |
| 79 | } |
| 80 | |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 81 | v4l2_dbg(1, debug, sd, "write: %02x %02x\n", reg, val); |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 82 | |
Hans Verkuil | 099b8e7 | 2007-11-01 07:45:54 -0300 | [diff] [blame] | 83 | for (i = 0; i < 3; i++) |
| 84 | if (i2c_smbus_write_byte_data(client, |
| 85 | (reg << 1) | (val >> 8), val & 0xff) == 0) |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 86 | return 0; |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 87 | v4l2_err(sd, "I2C: cannot write %03x to register R%d\n", val, reg); |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 88 | return -1; |
| 89 | } |
| 90 | |
| 91 | /* write regs to set audio volume etc */ |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 92 | static void wm8739_set_audio(struct v4l2_subdev *sd) |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 93 | { |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 94 | struct wm8739_state *state = to_state(sd); |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 95 | u16 mute = state->muted ? 0x80 : 0; |
| 96 | |
| 97 | /* Volume setting: bits 0-4, 0x1f = 12 dB, 0x00 = -34.5 dB |
| 98 | * Default setting: 0x17 = 0 dB |
| 99 | */ |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 100 | wm8739_write(sd, R0, (state->vol_l & 0x1f) | mute); |
| 101 | wm8739_write(sd, R1, (state->vol_r & 0x1f) | mute); |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 102 | } |
| 103 | |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 104 | static int wm8739_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 105 | { |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 106 | struct wm8739_state *state = to_state(sd); |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 107 | |
| 108 | switch (ctrl->id) { |
| 109 | case V4L2_CID_AUDIO_MUTE: |
| 110 | ctrl->value = state->muted; |
| 111 | break; |
| 112 | |
| 113 | case V4L2_CID_AUDIO_VOLUME: |
| 114 | ctrl->value = state->volume; |
| 115 | break; |
| 116 | |
| 117 | case V4L2_CID_AUDIO_BALANCE: |
| 118 | ctrl->value = state->balance; |
| 119 | break; |
| 120 | |
| 121 | default: |
| 122 | return -EINVAL; |
| 123 | } |
| 124 | return 0; |
| 125 | } |
| 126 | |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 127 | static int wm8739_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 128 | { |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 129 | struct wm8739_state *state = to_state(sd); |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 130 | unsigned int work_l, work_r; |
| 131 | |
| 132 | switch (ctrl->id) { |
| 133 | case V4L2_CID_AUDIO_MUTE: |
| 134 | state->muted = ctrl->value; |
| 135 | break; |
| 136 | |
| 137 | case V4L2_CID_AUDIO_VOLUME: |
| 138 | state->volume = ctrl->value; |
| 139 | break; |
| 140 | |
| 141 | case V4L2_CID_AUDIO_BALANCE: |
| 142 | state->balance = ctrl->value; |
| 143 | break; |
| 144 | |
| 145 | default: |
| 146 | return -EINVAL; |
| 147 | } |
| 148 | |
| 149 | /* normalize ( 65535 to 0 -> 31 to 0 (12dB to -34.5dB) ) */ |
| 150 | work_l = (min(65536 - state->balance, 32768) * state->volume) / 32768; |
| 151 | work_r = (min(state->balance, (u16)32768) * state->volume) / 32768; |
| 152 | |
| 153 | state->vol_l = (long)work_l * 31 / 65535; |
| 154 | state->vol_r = (long)work_r * 31 / 65535; |
| 155 | |
| 156 | /* set audio volume etc. */ |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 157 | wm8739_set_audio(sd); |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 158 | return 0; |
| 159 | } |
| 160 | |
| 161 | /* ------------------------------------------------------------------------ */ |
| 162 | |
| 163 | static struct v4l2_queryctrl wm8739_qctrl[] = { |
| 164 | { |
| 165 | .id = V4L2_CID_AUDIO_VOLUME, |
| 166 | .name = "Volume", |
| 167 | .minimum = 0, |
| 168 | .maximum = 65535, |
| 169 | .step = 65535/100, |
| 170 | .default_value = 58880, |
| 171 | .flags = 0, |
| 172 | .type = V4L2_CTRL_TYPE_INTEGER, |
Hans Verkuil | 099b8e7 | 2007-11-01 07:45:54 -0300 | [diff] [blame] | 173 | }, { |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 174 | .id = V4L2_CID_AUDIO_MUTE, |
| 175 | .name = "Mute", |
| 176 | .minimum = 0, |
| 177 | .maximum = 1, |
| 178 | .step = 1, |
| 179 | .default_value = 1, |
| 180 | .flags = 0, |
| 181 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
Hans Verkuil | 099b8e7 | 2007-11-01 07:45:54 -0300 | [diff] [blame] | 182 | }, { |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 183 | .id = V4L2_CID_AUDIO_BALANCE, |
| 184 | .name = "Balance", |
| 185 | .minimum = 0, |
| 186 | .maximum = 65535, |
| 187 | .step = 65535/100, |
| 188 | .default_value = 32768, |
| 189 | .flags = 0, |
| 190 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 191 | } |
| 192 | }; |
| 193 | |
| 194 | /* ------------------------------------------------------------------------ */ |
| 195 | |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 196 | static int wm8739_s_clock_freq(struct v4l2_subdev *sd, u32 audiofreq) |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 197 | { |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 198 | struct wm8739_state *state = to_state(sd); |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 199 | |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 200 | state->clock_freq = audiofreq; |
| 201 | /* de-activate */ |
| 202 | wm8739_write(sd, R9, 0x000); |
| 203 | switch (audiofreq) { |
| 204 | case 44100: |
| 205 | /* 256fps, fs=44.1k */ |
| 206 | wm8739_write(sd, R8, 0x020); |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 207 | break; |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 208 | case 48000: |
| 209 | /* 256fps, fs=48k */ |
| 210 | wm8739_write(sd, R8, 0x000); |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 211 | break; |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 212 | case 32000: |
| 213 | /* 256fps, fs=32k */ |
| 214 | wm8739_write(sd, R8, 0x018); |
| 215 | break; |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 216 | default: |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 217 | break; |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 218 | } |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 219 | /* activate */ |
| 220 | wm8739_write(sd, R9, 0x001); |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 221 | return 0; |
| 222 | } |
| 223 | |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 224 | static int wm8739_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc) |
| 225 | { |
| 226 | int i; |
| 227 | |
| 228 | for (i = 0; i < ARRAY_SIZE(wm8739_qctrl); i++) |
| 229 | if (qc->id && qc->id == wm8739_qctrl[i].id) { |
| 230 | memcpy(qc, &wm8739_qctrl[i], sizeof(*qc)); |
| 231 | return 0; |
| 232 | } |
| 233 | return -EINVAL; |
| 234 | } |
| 235 | |
Hans Verkuil | aecde8b | 2008-12-30 07:14:19 -0300 | [diff] [blame] | 236 | static int wm8739_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 237 | { |
| 238 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
| 239 | |
| 240 | return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_WM8739, 0); |
| 241 | } |
| 242 | |
| 243 | static int wm8739_log_status(struct v4l2_subdev *sd) |
| 244 | { |
| 245 | struct wm8739_state *state = to_state(sd); |
| 246 | |
| 247 | v4l2_info(sd, "Frequency: %u Hz\n", state->clock_freq); |
| 248 | v4l2_info(sd, "Volume L: %02x%s\n", state->vol_l & 0x1f, |
| 249 | state->muted ? " (muted)" : ""); |
| 250 | v4l2_info(sd, "Volume R: %02x%s\n", state->vol_r & 0x1f, |
| 251 | state->muted ? " (muted)" : ""); |
| 252 | return 0; |
| 253 | } |
| 254 | |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 255 | /* ----------------------------------------------------------------------- */ |
| 256 | |
| 257 | static const struct v4l2_subdev_core_ops wm8739_core_ops = { |
| 258 | .log_status = wm8739_log_status, |
| 259 | .g_chip_ident = wm8739_g_chip_ident, |
| 260 | .queryctrl = wm8739_queryctrl, |
| 261 | .g_ctrl = wm8739_g_ctrl, |
| 262 | .s_ctrl = wm8739_s_ctrl, |
| 263 | }; |
| 264 | |
| 265 | static const struct v4l2_subdev_audio_ops wm8739_audio_ops = { |
| 266 | .s_clock_freq = wm8739_s_clock_freq, |
| 267 | }; |
| 268 | |
| 269 | static const struct v4l2_subdev_ops wm8739_ops = { |
| 270 | .core = &wm8739_core_ops, |
| 271 | .audio = &wm8739_audio_ops, |
| 272 | }; |
| 273 | |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 274 | /* ------------------------------------------------------------------------ */ |
| 275 | |
| 276 | /* i2c implementation */ |
| 277 | |
Jean Delvare | d2653e9 | 2008-04-29 23:11:39 +0200 | [diff] [blame] | 278 | static int wm8739_probe(struct i2c_client *client, |
| 279 | const struct i2c_device_id *id) |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 280 | { |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 281 | struct wm8739_state *state; |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 282 | struct v4l2_subdev *sd; |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 283 | |
Hans Verkuil | 188f345 | 2007-09-16 10:47:15 -0300 | [diff] [blame] | 284 | /* Check if the adapter supports the needed features */ |
| 285 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
| 286 | return -EIO; |
| 287 | |
Hans Verkuil | 099b8e7 | 2007-11-01 07:45:54 -0300 | [diff] [blame] | 288 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
| 289 | client->addr << 1, client->adapter->name); |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 290 | |
| 291 | state = kmalloc(sizeof(struct wm8739_state), GFP_KERNEL); |
Hans Verkuil | 6c832e3 | 2008-08-24 06:29:30 -0300 | [diff] [blame] | 292 | if (state == NULL) |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 293 | return -ENOMEM; |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 294 | sd = &state->sd; |
| 295 | v4l2_i2c_subdev_init(sd, client, &wm8739_ops); |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 296 | state->vol_l = 0x17; /* 0dB */ |
| 297 | state->vol_r = 0x17; /* 0dB */ |
| 298 | state->muted = 0; |
| 299 | state->balance = 32768; |
| 300 | /* normalize (12dB(31) to -34.5dB(0) [0dB(23)] -> 65535 to 0) */ |
| 301 | state->volume = ((long)state->vol_l + 1) * 65535 / 31; |
| 302 | state->clock_freq = 48000; |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 303 | |
Hans Verkuil | 099b8e7 | 2007-11-01 07:45:54 -0300 | [diff] [blame] | 304 | /* Initialize wm8739 */ |
| 305 | |
| 306 | /* reset */ |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 307 | wm8739_write(sd, R15, 0x00); |
Hans Verkuil | 099b8e7 | 2007-11-01 07:45:54 -0300 | [diff] [blame] | 308 | /* filter setting, high path, offet clear */ |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 309 | wm8739_write(sd, R5, 0x000); |
Hans Verkuil | 099b8e7 | 2007-11-01 07:45:54 -0300 | [diff] [blame] | 310 | /* ADC, OSC, Power Off mode Disable */ |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 311 | wm8739_write(sd, R6, 0x000); |
Hans Verkuil | 099b8e7 | 2007-11-01 07:45:54 -0300 | [diff] [blame] | 312 | /* Digital Audio interface format: |
| 313 | Enable Master mode, 24 bit, MSB first/left justified */ |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 314 | wm8739_write(sd, R7, 0x049); |
Hans Verkuil | 099b8e7 | 2007-11-01 07:45:54 -0300 | [diff] [blame] | 315 | /* sampling control: normal, 256fs, 48KHz sampling rate */ |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 316 | wm8739_write(sd, R8, 0x000); |
Hans Verkuil | 099b8e7 | 2007-11-01 07:45:54 -0300 | [diff] [blame] | 317 | /* activate */ |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 318 | wm8739_write(sd, R9, 0x001); |
Hans Verkuil | 099b8e7 | 2007-11-01 07:45:54 -0300 | [diff] [blame] | 319 | /* set volume/mute */ |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 320 | wm8739_set_audio(sd); |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 321 | return 0; |
| 322 | } |
| 323 | |
Hans Verkuil | 49457cc | 2007-09-13 11:10:07 -0300 | [diff] [blame] | 324 | static int wm8739_remove(struct i2c_client *client) |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 325 | { |
Hans Verkuil | f1460e9 | 2008-11-29 13:02:26 -0300 | [diff] [blame] | 326 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
| 327 | |
| 328 | v4l2_device_unregister_subdev(sd); |
| 329 | kfree(to_state(sd)); |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 330 | return 0; |
| 331 | } |
| 332 | |
Jean Delvare | af29486 | 2008-05-18 20:49:40 +0200 | [diff] [blame] | 333 | static const struct i2c_device_id wm8739_id[] = { |
| 334 | { "wm8739", 0 }, |
| 335 | { } |
| 336 | }; |
| 337 | MODULE_DEVICE_TABLE(i2c, wm8739_id); |
| 338 | |
Hans Verkuil | 49457cc | 2007-09-13 11:10:07 -0300 | [diff] [blame] | 339 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { |
| 340 | .name = "wm8739", |
Hans Verkuil | 49457cc | 2007-09-13 11:10:07 -0300 | [diff] [blame] | 341 | .probe = wm8739_probe, |
| 342 | .remove = wm8739_remove, |
Jean Delvare | af29486 | 2008-05-18 20:49:40 +0200 | [diff] [blame] | 343 | .id_table = wm8739_id, |
Hans Verkuil | 75c4570 | 2006-03-28 18:23:48 -0300 | [diff] [blame] | 344 | }; |