Lines Matching +full:- +full:- +full:mode +full:- +full:-

1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
3 // Copyright (c) 2017-2018, Linaro Limited
10 #include "wcd-clsh-v2.h"
14 int mode; member
22 /* Class-H registers for codecs from and above WCD9335 */
109 struct snd_soc_component *comp = ctrl->comp; in wcd_enable_clsh_block()
111 if ((enable && ++ctrl->clsh_users == 1) || in wcd_enable_clsh_block()
112 (!enable && --ctrl->clsh_users == 0)) in wcd_enable_clsh_block()
116 if (ctrl->clsh_users < 0) in wcd_enable_clsh_block()
117 ctrl->clsh_users = 0; in wcd_enable_clsh_block()
127 int mode) in wcd_clsh_set_buck_mode() argument
130 if (mode == CLS_H_HIFI) in wcd_clsh_set_buck_mode()
141 int mode) in wcd_clsh_set_flyback_mode() argument
144 if (mode == CLS_H_HIFI) in wcd_clsh_set_flyback_mode()
155 int mode, in wcd_clsh_buck_ctrl() argument
158 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_buck_ctrl()
161 if ((enable && (++ctrl->buck_users == 1)) || in wcd_clsh_buck_ctrl()
162 (!enable && (--ctrl->buck_users == 0))) in wcd_clsh_buck_ctrl()
174 int mode, in wcd_clsh_flyback_ctrl() argument
177 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_flyback_ctrl()
180 if ((enable && (++ctrl->flyback_users == 1)) || in wcd_clsh_flyback_ctrl()
181 (!enable && (--ctrl->flyback_users == 0))) { in wcd_clsh_flyback_ctrl()
195 static void wcd_clsh_set_gain_path(struct wcd_clsh_ctrl *ctrl, int mode) in wcd_clsh_set_gain_path() argument
197 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_set_gain_path()
200 switch (mode) { in wcd_clsh_set_gain_path()
223 int mode) in wcd_clsh_set_hph_mode() argument
229 switch (mode) { in wcd_clsh_set_hph_mode()
257 if (mode != CLS_H_LP) in wcd_clsh_set_hph_mode()
268 int mode) in wcd_clsh_set_flyback_current() argument
280 int mode) in wcd_clsh_set_buck_regulator_mode() argument
282 if (mode == CLS_AB) in wcd_clsh_set_buck_regulator_mode()
293 bool is_enable, int mode) in wcd_clsh_state_lo() argument
295 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_state_lo()
297 if (mode != CLS_AB) { in wcd_clsh_state_lo()
298 dev_err(comp->dev, "%s: LO cannot be in this mode: %d\n", in wcd_clsh_state_lo()
299 __func__, mode); in wcd_clsh_state_lo()
304 wcd_clsh_set_buck_regulator_mode(comp, mode); in wcd_clsh_state_lo()
305 wcd_clsh_set_buck_mode(comp, mode); in wcd_clsh_state_lo()
306 wcd_clsh_set_flyback_mode(comp, mode); in wcd_clsh_state_lo()
307 wcd_clsh_flyback_ctrl(ctrl, mode, true); in wcd_clsh_state_lo()
308 wcd_clsh_set_flyback_current(comp, mode); in wcd_clsh_state_lo()
309 wcd_clsh_buck_ctrl(ctrl, mode, true); in wcd_clsh_state_lo()
311 wcd_clsh_buck_ctrl(ctrl, mode, false); in wcd_clsh_state_lo()
312 wcd_clsh_flyback_ctrl(ctrl, mode, false); in wcd_clsh_state_lo()
320 bool is_enable, int mode) in wcd_clsh_state_hph_r() argument
322 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_state_hph_r()
324 if (mode == CLS_H_NORMAL) { in wcd_clsh_state_hph_r()
325 dev_err(comp->dev, "%s: Normal mode not applicable for hph_r\n", in wcd_clsh_state_hph_r()
331 if (mode != CLS_AB) { in wcd_clsh_state_hph_r()
350 wcd_clsh_set_buck_regulator_mode(comp, mode); in wcd_clsh_state_hph_r()
351 wcd_clsh_set_flyback_mode(comp, mode); in wcd_clsh_state_hph_r()
352 wcd_clsh_flyback_ctrl(ctrl, mode, true); in wcd_clsh_state_hph_r()
353 wcd_clsh_set_flyback_current(comp, mode); in wcd_clsh_state_hph_r()
354 wcd_clsh_set_buck_mode(comp, mode); in wcd_clsh_state_hph_r()
355 wcd_clsh_buck_ctrl(ctrl, mode, true); in wcd_clsh_state_hph_r()
356 wcd_clsh_set_hph_mode(comp, mode); in wcd_clsh_state_hph_r()
357 wcd_clsh_set_gain_path(ctrl, mode); in wcd_clsh_state_hph_r()
361 if (mode != CLS_AB) { in wcd_clsh_state_hph_r()
368 /* buck and flyback set to default mode and disable */ in wcd_clsh_state_hph_r()
378 bool is_enable, int mode) in wcd_clsh_state_hph_l() argument
380 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_state_hph_l()
382 if (mode == CLS_H_NORMAL) { in wcd_clsh_state_hph_l()
383 dev_err(comp->dev, "%s: Normal mode not applicable for hph_l\n", in wcd_clsh_state_hph_l()
389 if (mode != CLS_AB) { in wcd_clsh_state_hph_l()
408 wcd_clsh_set_buck_regulator_mode(comp, mode); in wcd_clsh_state_hph_l()
409 wcd_clsh_set_flyback_mode(comp, mode); in wcd_clsh_state_hph_l()
410 wcd_clsh_flyback_ctrl(ctrl, mode, true); in wcd_clsh_state_hph_l()
411 wcd_clsh_set_flyback_current(comp, mode); in wcd_clsh_state_hph_l()
412 wcd_clsh_set_buck_mode(comp, mode); in wcd_clsh_state_hph_l()
413 wcd_clsh_buck_ctrl(ctrl, mode, true); in wcd_clsh_state_hph_l()
414 wcd_clsh_set_hph_mode(comp, mode); in wcd_clsh_state_hph_l()
415 wcd_clsh_set_gain_path(ctrl, mode); in wcd_clsh_state_hph_l()
419 if (mode != CLS_AB) { in wcd_clsh_state_hph_l()
426 /* set buck and flyback to Default Mode */ in wcd_clsh_state_hph_l()
436 bool is_enable, int mode) in wcd_clsh_state_ear() argument
438 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_state_ear()
440 if (mode != CLS_H_NORMAL) { in wcd_clsh_state_ear()
441 dev_err(comp->dev, "%s: mode: %d cannot be used for EAR\n", in wcd_clsh_state_ear()
442 __func__, mode); in wcd_clsh_state_ear()
452 wcd_clsh_set_buck_mode(comp, mode); in wcd_clsh_state_ear()
453 wcd_clsh_set_flyback_mode(comp, mode); in wcd_clsh_state_ear()
454 wcd_clsh_flyback_ctrl(ctrl, mode, true); in wcd_clsh_state_ear()
455 wcd_clsh_set_flyback_current(comp, mode); in wcd_clsh_state_ear()
456 wcd_clsh_buck_ctrl(ctrl, mode, true); in wcd_clsh_state_ear()
463 wcd_clsh_buck_ctrl(ctrl, mode, false); in wcd_clsh_state_ear()
464 wcd_clsh_flyback_ctrl(ctrl, mode, false); in wcd_clsh_state_ear()
471 bool is_enable, int mode) in _wcd_clsh_ctrl_set_state() argument
475 wcd_clsh_state_ear(ctrl, req_state, is_enable, mode); in _wcd_clsh_ctrl_set_state()
478 wcd_clsh_state_hph_l(ctrl, req_state, is_enable, mode); in _wcd_clsh_ctrl_set_state()
481 wcd_clsh_state_hph_r(ctrl, req_state, is_enable, mode); in _wcd_clsh_ctrl_set_state()
485 wcd_clsh_state_lo(ctrl, req_state, is_enable, mode); in _wcd_clsh_ctrl_set_state()
526 enum wcd_clsh_mode mode) in wcd_clsh_ctrl_set_state() argument
528 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_ctrl_set_state()
530 if (nstate == ctrl->state) in wcd_clsh_ctrl_set_state()
534 dev_err(comp->dev, "Class-H not a valid new state:\n"); in wcd_clsh_ctrl_set_state()
535 return -EINVAL; in wcd_clsh_ctrl_set_state()
540 _wcd_clsh_ctrl_set_state(ctrl, nstate, CLSH_REQ_ENABLE, mode); in wcd_clsh_ctrl_set_state()
543 _wcd_clsh_ctrl_set_state(ctrl, nstate, CLSH_REQ_DISABLE, mode); in wcd_clsh_ctrl_set_state()
547 ctrl->state = nstate; in wcd_clsh_ctrl_set_state()
548 ctrl->mode = mode; in wcd_clsh_ctrl_set_state()
555 return ctrl->state; in wcd_clsh_ctrl_get_state()
565 return ERR_PTR(-ENOMEM); in wcd_clsh_ctrl_alloc()
567 ctrl->state = WCD_CLSH_STATE_IDLE; in wcd_clsh_ctrl_alloc()
568 ctrl->comp = comp; in wcd_clsh_ctrl_alloc()