9 #include <linux/slab.h>
14 #define PMF_GPIO(name, bit) \
15 static void pmf_gpio_set_##name(struct gpio_runtime *rt, int on)\
17 struct pmf_args args = { .count = 1, .u[0].v = !on }; \
20 if (unlikely(!rt)) return; \
21 rc = pmf_call_function(rt->node, #name "-mute", &args); \
22 if (rc && rc != -ENODEV) \
23 printk(KERN_WARNING "pmf_gpio_set_" #name \
24 " failed, rc: %d\n", rc); \
25 rt->implementation_private &= ~(1<<bit); \
26 rt->implementation_private |= (!!on << bit); \
28 static int pmf_gpio_get_##name(struct gpio_runtime *rt) \
30 if (unlikely(!rt)) return 0; \
31 return (rt->implementation_private>>bit)&1; \
38 static void pmf_gpio_set_hw_reset(
struct gpio_runtime *rt,
int on)
47 " failed, rc: %d\n", rc);
50 static void pmf_gpio_all_amps_off(
struct gpio_runtime *rt)
56 pmf_gpio_set_headphone(rt, 0);
57 pmf_gpio_set_amp(rt, 0);
58 pmf_gpio_set_lineout(rt, 0);
62 static void pmf_gpio_all_amps_restore(
struct gpio_runtime *rt)
68 pmf_gpio_set_headphone(rt, (s>>0)&1);
69 pmf_gpio_set_amp(rt, (s>>1)&1);
70 pmf_gpio_set_lineout(rt, (s>>2)&1);
86 pmf_gpio_all_amps_off(rt);
98 pmf_gpio_all_amps_off(rt);
123 static void pmf_handle_notify_irq(
void *
data)
144 name =
"headphone-detect";
148 name =
"linein-detect";
152 name =
"lineout-detect";
162 if (!old && !notify) {
168 if (old == notify && notif->
data == data)
173 if (old && !notify) {
179 if (!old && notify) {
186 irq_client->
data = notif;
187 irq_client->
handler = pmf_handle_notify_irq;
194 " register %s irq (%d)\n", name, err);
218 name =
"headphone-detect";
221 name =
"linein-detect";
224 name =
"lineout-detect";
237 .init = pmf_gpio_init,
238 .exit = pmf_gpio_exit,
239 .all_amps_off = pmf_gpio_all_amps_off,
240 .all_amps_restore = pmf_gpio_all_amps_restore,
241 .set_headphone = pmf_gpio_set_headphone,
242 .set_speakers = pmf_gpio_set_amp,
243 .set_lineout = pmf_gpio_set_lineout,
244 .set_hw_reset = pmf_gpio_set_hw_reset,
245 .get_headphone = pmf_gpio_get_headphone,
246 .get_speakers = pmf_gpio_get_amp,
247 .get_lineout = pmf_gpio_get_lineout,
248 .set_notify = pmf_set_notify,
249 .get_detect = pmf_get_detect,