24 #include <linux/module.h>
25 #include <linux/types.h>
26 #include <linux/slab.h>
28 #include <asm/uaccess.h>
29 #include <linux/i2c.h>
30 #include <linux/videodev2.h>
84 v4l2_err(sd,
"Invalid register R%d\n", reg);
90 for (i = 0; i < 3; i++)
92 (reg << 1) | (val >> 8), val & 0xff) == 0)
94 v4l2_err(sd,
"I2C: cannot write %03x to register R%d\n", val, reg);
102 unsigned int work_l, work_r;
116 work_l = (
min(65536 - state->
balance->val, 32768) * state->
volume->val) / 32768;
119 vol_l = (
long)work_l * 31 / 65535;
120 vol_r = (
long)work_r * 31 / 65535;
123 mute = state->
mute->val ? 0x80 : 0;
128 wm8739_write(sd,
R0, (vol_l & 0x1f) | mute);
129 wm8739_write(sd,
R1, (vol_r & 0x1f) | mute);
135 static int wm8739_s_clock_freq(
struct v4l2_subdev *sd,
u32 audiofreq)
141 wm8739_write(sd,
R9, 0x000);
145 wm8739_write(sd,
R8, 0x020);
149 wm8739_write(sd,
R8, 0x000);
153 wm8739_write(sd,
R8, 0x018);
159 wm8739_write(sd,
R9, 0x001);
165 struct i2c_client *client = v4l2_get_subdevdata(sd);
170 static int wm8739_log_status(
struct v4l2_subdev *sd)
182 .s_ctrl = wm8739_s_ctrl,
186 .log_status = wm8739_log_status,
187 .g_chip_ident = wm8739_g_chip_ident,
198 .s_clock_freq = wm8739_s_clock_freq,
202 .core = &wm8739_core_ops,
203 .audio = &wm8739_audio_ops,
210 static int wm8739_probe(
struct i2c_client *client,
220 v4l_info(client,
"chip found @ 0x%x (%s)\n",
236 if (state->
hdl.error) {
237 int err = state->
hdl.error;
250 wm8739_write(sd,
R15, 0x00);
252 wm8739_write(sd,
R5, 0x000);
254 wm8739_write(sd,
R6, 0x000);
257 wm8739_write(sd,
R7, 0x049);
259 wm8739_write(sd,
R8, 0x000);
261 wm8739_write(sd,
R9, 0x001);
267 static int wm8739_remove(
struct i2c_client *client)
269 struct v4l2_subdev *sd = i2c_get_clientdata(client);
289 .probe = wm8739_probe,
290 .remove = wm8739_remove,
291 .id_table = wm8739_id,