Lines Matching +full:audio +full:- +full:gain +full:- +full:db

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * wm8775 - driver version 0.0.1
10 * - Cleanup
11 * - V4L2 API update
12 * - sound fixes
22 #include <media/v4l2-device.h>
23 #include <media/v4l2-ctrls.h>
32 /* ----------------------------------------------------------------------- */
50 u8 input; /* Last selected input (0-0xf) */
60 return &container_of(ctrl->handler, struct wm8775_state, hdl)->sd; in to_sd()
70 return -1; in wm8775_write()
78 return -1; in wm8775_write()
85 int muted = 0 != state->mute->val; in wm8775_set_audio()
86 u16 volume = (u16)state->vol->val; in wm8775_set_audio()
87 u16 balance = (u16)state->bal->val; in wm8775_set_audio()
89 /* normalize ( 65535 to 0 -> 255 to 0 (+24dB to -103dB) ) */ in wm8775_set_audio()
90 vol_l = (min(65536 - balance, 32768) * volume) >> 23; in wm8775_set_audio()
95 wm8775_write(sd, R21, 0x0c0 | state->input); in wm8775_set_audio()
100 /* Un-mute */ in wm8775_set_audio()
102 wm8775_write(sd, R21, state->input); in wm8775_set_audio()
117 return -EINVAL; in wm8775_s_routing()
119 state->input = input; in wm8775_s_routing()
120 if (v4l2_ctrl_g_ctrl(state->mute)) in wm8775_s_routing()
122 if (!v4l2_ctrl_g_ctrl(state->vol)) in wm8775_s_routing()
132 switch (ctrl->id) { in wm8775_s_ctrl()
139 wm8775_write(sd, R17, (ctrl->val ? ALC_EN : 0) | ALC_HOLD); in wm8775_s_ctrl()
142 return -EINVAL; in wm8775_s_ctrl()
149 v4l2_info(sd, "Input: %d\n", state->input); in wm8775_log_status()
150 v4l2_ctrl_handler_log_status(&state->hdl, sd->name); in wm8775_log_status()
160 /* ----------------------------------------------------------------------- */
181 .audio = &wm8775_audio_ops,
184 /* ----------------------------------------------------------------------- */
200 if (client->dev.platform_data) { in wm8775_probe()
201 struct wm8775_platform_data *data = client->dev.platform_data; in wm8775_probe()
202 is_nova_s = data->is_nova_s; in wm8775_probe()
206 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) in wm8775_probe()
207 return -EIO; in wm8775_probe()
210 client->addr << 1, client->adapter->name); in wm8775_probe()
212 state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); in wm8775_probe()
214 return -ENOMEM; in wm8775_probe()
215 sd = &state->sd; in wm8775_probe()
217 state->input = 2; in wm8775_probe()
219 v4l2_ctrl_handler_init(&state->hdl, 4); in wm8775_probe()
220 state->mute = v4l2_ctrl_new_std(&state->hdl, &wm8775_ctrl_ops, in wm8775_probe()
222 state->vol = v4l2_ctrl_new_std(&state->hdl, &wm8775_ctrl_ops, in wm8775_probe()
223 V4L2_CID_AUDIO_VOLUME, 0, 65535, (65535+99)/100, 0xCF00); /* 0dB*/ in wm8775_probe()
224 state->bal = v4l2_ctrl_new_std(&state->hdl, &wm8775_ctrl_ops, in wm8775_probe()
226 state->loud = v4l2_ctrl_new_std(&state->hdl, &wm8775_ctrl_ops, in wm8775_probe()
228 sd->ctrl_handler = &state->hdl; in wm8775_probe()
229 err = state->hdl.error; in wm8775_probe()
231 v4l2_ctrl_handler_free(&state->hdl); in wm8775_probe()
241 /* HPF enable, left justified, 24-bit (Philips) mode */ in wm8775_probe()
249 /* ADC gain +2.5dB, enable zero cross */ in wm8775_probe()
251 /* ADC gain +2.5dB, enable zero cross */ in wm8775_probe()
253 /* ALC Stereo, ALC target level -1dB FS max gain +8dB */ in wm8775_probe()
255 /* Enable gain control, use zero cross detection, in wm8775_probe()
259 /* ALC stereo, ALC target level -5dB FS, ALC max gain +8dB */ in wm8775_probe()
262 wm8775_write(sd, R17, (state->loud->val ? ALC_EN : 0) | ALC_HOLD); in wm8775_probe()
264 /* ALC gain ramp up delay 34 s, ALC gain ramp down delay 33 ms */ in wm8775_probe()
266 /* Enable noise gate, threshold -72dBfs */ in wm8775_probe()
269 /* Transient window 4ms, lower PGA gain limit -1dB */ in wm8775_probe()
274 /* Transient window 4ms, ALC min gain -5dB */ in wm8775_probe()
288 v4l2_ctrl_handler_free(&state->hdl); in wm8775_remove()