Lines Matching +full:msb +full:- +full:justified
1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (C) 2005 T. Adachi <tadachi@tadachi-net.com>
8 * - Cleanup
18 #include <media/v4l2-device.h>
19 #include <media/v4l2-ctrls.h>
29 MODULE_PARM_DESC(debug, "Debug level (0-1)");
32 /* ------------------------------------------------------------------------ */
59 return &container_of(ctrl->handler, struct wm8739_state, hdl)->sd; in to_sd()
62 /* ------------------------------------------------------------------------ */
71 return -1; in wm8739_write()
81 return -1; in wm8739_write()
89 u8 vol_l; /* +12dB to -34.5dB 1.5dB step (5bit) def:0dB */ in wm8739_s_ctrl()
90 u8 vol_r; /* +12dB to -34.5dB 1.5dB step (5bit) def:0dB */ in wm8739_s_ctrl()
93 switch (ctrl->id) { in wm8739_s_ctrl()
98 return -EINVAL; in wm8739_s_ctrl()
101 /* normalize ( 65535 to 0 -> 31 to 0 (12dB to -34.5dB) ) */ in wm8739_s_ctrl()
102 work_l = (min(65536 - state->balance->val, 32768) * state->volume->val) / 32768; in wm8739_s_ctrl()
103 work_r = (min(state->balance->val, 32768) * state->volume->val) / 32768; in wm8739_s_ctrl()
109 mute = state->mute->val ? 0x80 : 0; in wm8739_s_ctrl()
111 /* Volume setting: bits 0-4, 0x1f = 12 dB, 0x00 = -34.5 dB in wm8739_s_ctrl()
119 /* ------------------------------------------------------------------------ */
125 state->clock_freq = audiofreq; in wm8739_s_clock_freq()
126 /* de-activate */ in wm8739_s_clock_freq()
153 v4l2_info(sd, "Frequency: %u Hz\n", state->clock_freq); in wm8739_log_status()
154 v4l2_ctrl_handler_log_status(&state->hdl, sd->name); in wm8739_log_status()
158 /* ----------------------------------------------------------------------- */
177 /* ------------------------------------------------------------------------ */
187 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) in wm8739_probe()
188 return -EIO; in wm8739_probe()
191 client->addr << 1, client->adapter->name); in wm8739_probe()
193 state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); in wm8739_probe()
195 return -ENOMEM; in wm8739_probe()
196 sd = &state->sd; in wm8739_probe()
198 v4l2_ctrl_handler_init(&state->hdl, 2); in wm8739_probe()
199 state->volume = v4l2_ctrl_new_std(&state->hdl, &wm8739_ctrl_ops, in wm8739_probe()
201 state->mute = v4l2_ctrl_new_std(&state->hdl, &wm8739_ctrl_ops, in wm8739_probe()
203 state->balance = v4l2_ctrl_new_std(&state->hdl, &wm8739_ctrl_ops, in wm8739_probe()
205 sd->ctrl_handler = &state->hdl; in wm8739_probe()
206 if (state->hdl.error) { in wm8739_probe()
207 int err = state->hdl.error; in wm8739_probe()
209 v4l2_ctrl_handler_free(&state->hdl); in wm8739_probe()
212 v4l2_ctrl_cluster(3, &state->volume); in wm8739_probe()
214 state->clock_freq = 48000; in wm8739_probe()
225 Enable Master mode, 24 bit, MSB first/left justified */ in wm8739_probe()
232 v4l2_ctrl_handler_setup(&state->hdl); in wm8739_probe()
242 v4l2_ctrl_handler_free(&state->hdl); in wm8739_remove()