Lines Matching full:ctrl
119 static inline void wcd_enable_clsh_block(struct wcd_clsh_ctrl *ctrl, in wcd_enable_clsh_block() argument
122 struct snd_soc_component *comp = ctrl->comp; in wcd_enable_clsh_block()
124 if ((enable && ++ctrl->clsh_users == 1) || in wcd_enable_clsh_block()
125 (!enable && --ctrl->clsh_users == 0)) in wcd_enable_clsh_block()
129 if (ctrl->clsh_users < 0) in wcd_enable_clsh_block()
130 ctrl->clsh_users = 0; in wcd_enable_clsh_block()
175 static void wcd_clsh_buck_ctrl(struct wcd_clsh_ctrl *ctrl, in wcd_clsh_buck_ctrl() argument
179 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_buck_ctrl()
182 if ((enable && (++ctrl->buck_users == 1)) || in wcd_clsh_buck_ctrl()
183 (!enable && (--ctrl->buck_users == 0))) in wcd_clsh_buck_ctrl()
195 struct wcd_clsh_ctrl *ctrl, in wcd_clsh_v3_buck_ctrl() argument
200 if ((enable && (++ctrl->buck_users == 1)) || in wcd_clsh_v3_buck_ctrl()
201 (!enable && (--ctrl->buck_users == 0))) { in wcd_clsh_v3_buck_ctrl()
224 static void wcd_clsh_flyback_ctrl(struct wcd_clsh_ctrl *ctrl, in wcd_clsh_flyback_ctrl() argument
228 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_flyback_ctrl()
231 if ((enable && (++ctrl->flyback_users == 1)) || in wcd_clsh_flyback_ctrl()
232 (!enable && (--ctrl->flyback_users == 0))) { in wcd_clsh_flyback_ctrl()
246 static void wcd_clsh_set_gain_path(struct wcd_clsh_ctrl *ctrl, int mode) in wcd_clsh_set_gain_path() argument
248 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_set_gain_path()
348 void wcd_clsh_set_hph_mode(struct wcd_clsh_ctrl *ctrl, int mode) in wcd_clsh_set_hph_mode() argument
350 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_set_hph_mode()
352 if (ctrl->codec_version >= WCD937X) in wcd_clsh_set_hph_mode()
453 struct wcd_clsh_ctrl *ctrl, in wcd_clsh_v3_flyback_ctrl() argument
458 if ((enable && (++ctrl->flyback_users == 1)) || in wcd_clsh_v3_flyback_ctrl()
459 (!enable && (--ctrl->flyback_users == 0))) { in wcd_clsh_v3_flyback_ctrl()
490 static void wcd_clsh_v3_state_aux(struct wcd_clsh_ctrl *ctrl, int req_state, in wcd_clsh_v3_state_aux() argument
493 struct snd_soc_component *component = ctrl->comp; in wcd_clsh_v3_state_aux()
498 wcd_clsh_v3_flyback_ctrl(component, ctrl, mode, true); in wcd_clsh_v3_state_aux()
500 wcd_clsh_v3_buck_ctrl(component, ctrl, mode, true); in wcd_clsh_v3_state_aux()
502 wcd_clsh_v3_buck_ctrl(component, ctrl, mode, false); in wcd_clsh_v3_state_aux()
503 wcd_clsh_v3_flyback_ctrl(component, ctrl, mode, false); in wcd_clsh_v3_state_aux()
509 static void wcd_clsh_state_lo(struct wcd_clsh_ctrl *ctrl, int req_state, in wcd_clsh_state_lo() argument
512 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_state_lo()
524 wcd_clsh_flyback_ctrl(ctrl, mode, true); in wcd_clsh_state_lo()
526 wcd_clsh_buck_ctrl(ctrl, mode, true); in wcd_clsh_state_lo()
528 wcd_clsh_buck_ctrl(ctrl, mode, false); in wcd_clsh_state_lo()
529 wcd_clsh_flyback_ctrl(ctrl, mode, false); in wcd_clsh_state_lo()
536 static void wcd_clsh_v3_state_hph_r(struct wcd_clsh_ctrl *ctrl, int req_state, in wcd_clsh_v3_state_hph_r() argument
539 struct snd_soc_component *component = ctrl->comp; in wcd_clsh_v3_state_hph_r()
551 wcd_clsh_v3_flyback_ctrl(component, ctrl, mode, true); in wcd_clsh_v3_state_hph_r()
554 wcd_clsh_v3_buck_ctrl(component, ctrl, mode, true); in wcd_clsh_v3_state_hph_r()
560 wcd_clsh_v3_flyback_ctrl(component, ctrl, CLS_H_NORMAL, false); in wcd_clsh_v3_state_hph_r()
561 wcd_clsh_v3_buck_ctrl(component, ctrl, CLS_H_NORMAL, false); in wcd_clsh_v3_state_hph_r()
568 static void wcd_clsh_state_hph_r(struct wcd_clsh_ctrl *ctrl, int req_state, in wcd_clsh_state_hph_r() argument
571 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_state_hph_r()
581 wcd_enable_clsh_block(ctrl, true); in wcd_clsh_state_hph_r()
601 wcd_clsh_flyback_ctrl(ctrl, mode, true); in wcd_clsh_state_hph_r()
604 wcd_clsh_buck_ctrl(ctrl, mode, true); in wcd_clsh_state_hph_r()
606 wcd_clsh_set_gain_path(ctrl, mode); in wcd_clsh_state_hph_r()
615 wcd_enable_clsh_block(ctrl, false); in wcd_clsh_state_hph_r()
618 wcd_clsh_buck_ctrl(ctrl, CLS_H_NORMAL, false); in wcd_clsh_state_hph_r()
619 wcd_clsh_flyback_ctrl(ctrl, CLS_H_NORMAL, false); in wcd_clsh_state_hph_r()
626 static void wcd_clsh_v3_state_hph_l(struct wcd_clsh_ctrl *ctrl, int req_state, in wcd_clsh_v3_state_hph_l() argument
629 struct snd_soc_component *component = ctrl->comp; in wcd_clsh_v3_state_hph_l()
641 wcd_clsh_v3_flyback_ctrl(component, ctrl, mode, true); in wcd_clsh_v3_state_hph_l()
644 wcd_clsh_v3_buck_ctrl(component, ctrl, mode, true); in wcd_clsh_v3_state_hph_l()
650 wcd_clsh_v3_flyback_ctrl(component, ctrl, CLS_H_NORMAL, false); in wcd_clsh_v3_state_hph_l()
651 wcd_clsh_v3_buck_ctrl(component, ctrl, CLS_H_NORMAL, false); in wcd_clsh_v3_state_hph_l()
658 static void wcd_clsh_state_hph_l(struct wcd_clsh_ctrl *ctrl, int req_state, in wcd_clsh_state_hph_l() argument
661 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_state_hph_l()
671 wcd_enable_clsh_block(ctrl, true); in wcd_clsh_state_hph_l()
691 wcd_clsh_flyback_ctrl(ctrl, mode, true); in wcd_clsh_state_hph_l()
694 wcd_clsh_buck_ctrl(ctrl, mode, true); in wcd_clsh_state_hph_l()
696 wcd_clsh_set_gain_path(ctrl, mode); in wcd_clsh_state_hph_l()
705 wcd_enable_clsh_block(ctrl, false); in wcd_clsh_state_hph_l()
708 wcd_clsh_buck_ctrl(ctrl, CLS_H_NORMAL, false); in wcd_clsh_state_hph_l()
709 wcd_clsh_flyback_ctrl(ctrl, CLS_H_NORMAL, false); in wcd_clsh_state_hph_l()
716 static void wcd_clsh_v3_state_ear(struct wcd_clsh_ctrl *ctrl, int req_state, in wcd_clsh_v3_state_ear() argument
719 struct snd_soc_component *component = ctrl->comp; in wcd_clsh_v3_state_ear()
725 wcd_clsh_v3_flyback_ctrl(component, ctrl, mode, true); in wcd_clsh_v3_state_ear()
728 wcd_clsh_v3_buck_ctrl(component, ctrl, mode, true); in wcd_clsh_v3_state_ear()
734 wcd_clsh_v3_flyback_ctrl(component, ctrl, CLS_H_NORMAL, false); in wcd_clsh_v3_state_ear()
735 wcd_clsh_v3_buck_ctrl(component, ctrl, CLS_H_NORMAL, false); in wcd_clsh_v3_state_ear()
742 static void wcd_clsh_state_ear(struct wcd_clsh_ctrl *ctrl, int req_state, in wcd_clsh_state_ear() argument
745 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_state_ear()
754 wcd_enable_clsh_block(ctrl, true); in wcd_clsh_state_ear()
761 wcd_clsh_flyback_ctrl(ctrl, mode, true); in wcd_clsh_state_ear()
763 wcd_clsh_buck_ctrl(ctrl, mode, true); in wcd_clsh_state_ear()
769 wcd_enable_clsh_block(ctrl, false); in wcd_clsh_state_ear()
770 wcd_clsh_buck_ctrl(ctrl, mode, false); in wcd_clsh_state_ear()
771 wcd_clsh_flyback_ctrl(ctrl, mode, false); in wcd_clsh_state_ear()
777 static int _wcd_clsh_ctrl_set_state(struct wcd_clsh_ctrl *ctrl, int req_state, in _wcd_clsh_ctrl_set_state() argument
782 if (ctrl->codec_version >= WCD937X) in _wcd_clsh_ctrl_set_state()
783 wcd_clsh_v3_state_ear(ctrl, req_state, is_enable, mode); in _wcd_clsh_ctrl_set_state()
785 wcd_clsh_state_ear(ctrl, req_state, is_enable, mode); in _wcd_clsh_ctrl_set_state()
788 if (ctrl->codec_version >= WCD937X) in _wcd_clsh_ctrl_set_state()
789 wcd_clsh_v3_state_hph_l(ctrl, req_state, is_enable, mode); in _wcd_clsh_ctrl_set_state()
791 wcd_clsh_state_hph_l(ctrl, req_state, is_enable, mode); in _wcd_clsh_ctrl_set_state()
794 if (ctrl->codec_version >= WCD937X) in _wcd_clsh_ctrl_set_state()
795 wcd_clsh_v3_state_hph_r(ctrl, req_state, is_enable, mode); in _wcd_clsh_ctrl_set_state()
797 wcd_clsh_state_hph_r(ctrl, req_state, is_enable, mode); in _wcd_clsh_ctrl_set_state()
800 if (ctrl->codec_version < WCD937X) in _wcd_clsh_ctrl_set_state()
801 wcd_clsh_state_lo(ctrl, req_state, is_enable, mode); in _wcd_clsh_ctrl_set_state()
804 if (ctrl->codec_version >= WCD937X) in _wcd_clsh_ctrl_set_state()
805 wcd_clsh_v3_state_aux(ctrl, req_state, is_enable, mode); in _wcd_clsh_ctrl_set_state()
837 * Params: ctrl, req_state, req_type, clsh_event
841 * based on validity of their states. ctrl will contain current
844 int wcd_clsh_ctrl_set_state(struct wcd_clsh_ctrl *ctrl, in wcd_clsh_ctrl_set_state() argument
849 struct snd_soc_component *comp = ctrl->comp; in wcd_clsh_ctrl_set_state()
851 if (nstate == ctrl->state) in wcd_clsh_ctrl_set_state()
861 _wcd_clsh_ctrl_set_state(ctrl, nstate, CLSH_REQ_ENABLE, mode); in wcd_clsh_ctrl_set_state()
864 _wcd_clsh_ctrl_set_state(ctrl, nstate, CLSH_REQ_DISABLE, mode); in wcd_clsh_ctrl_set_state()
868 ctrl->state = nstate; in wcd_clsh_ctrl_set_state()
869 ctrl->mode = mode; in wcd_clsh_ctrl_set_state()
875 int wcd_clsh_ctrl_get_state(struct wcd_clsh_ctrl *ctrl) in wcd_clsh_ctrl_get_state() argument
877 return ctrl->state; in wcd_clsh_ctrl_get_state()
884 struct wcd_clsh_ctrl *ctrl; in wcd_clsh_ctrl_alloc() local
886 ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); in wcd_clsh_ctrl_alloc()
887 if (!ctrl) in wcd_clsh_ctrl_alloc()
890 ctrl->state = WCD_CLSH_STATE_IDLE; in wcd_clsh_ctrl_alloc()
891 ctrl->comp = comp; in wcd_clsh_ctrl_alloc()
892 ctrl->codec_version = version; in wcd_clsh_ctrl_alloc()
894 return ctrl; in wcd_clsh_ctrl_alloc()
898 void wcd_clsh_ctrl_free(struct wcd_clsh_ctrl *ctrl) in wcd_clsh_ctrl_free() argument
900 kfree(ctrl); in wcd_clsh_ctrl_free()