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