summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--target/linux/s3c24xx/files-2.6.30/drivers/input/keyboard/gta02kbd.c167
-rw-r--r--target/linux/s3c24xx/files-2.6.30/sound/soc/s3c24xx/gta02_wm8753.c64
2 files changed, 64 insertions, 167 deletions
diff --git a/target/linux/s3c24xx/files-2.6.30/drivers/input/keyboard/gta02kbd.c b/target/linux/s3c24xx/files-2.6.30/drivers/input/keyboard/gta02kbd.c
index 0814d10..0fca170 100644
--- a/target/linux/s3c24xx/files-2.6.30/drivers/input/keyboard/gta02kbd.c
+++ b/target/linux/s3c24xx/files-2.6.30/drivers/input/keyboard/gta02kbd.c
@@ -21,7 +21,6 @@
#include <linux/jiffies.h>
#include <linux/module.h>
#include <linux/slab.h>
-#include <linux/workqueue.h>
#include <mach/gpio.h>
#include <asm/mach-types.h>
@@ -35,21 +34,12 @@ extern int global_inside_suspend;
struct gta02kbd {
struct platform_device *pdev;
struct input_dev *input;
- struct device *cdev;
- struct work_struct work;
int aux_state;
- int work_in_progress;
- int hp_irq_count_in_work;
- int hp_irq_count;
- int jack_irq;
};
-static struct class *gta02kbd_switch_class;
-
enum keys {
GTA02_KEY_AUX,
GTA02_KEY_HOLD,
- GTA02_KEY_JACK,
};
struct gta02kbd_key {
@@ -60,7 +50,6 @@ struct gta02kbd_key {
};
static irqreturn_t gta02kbd_aux_irq(int irq, void *dev_id);
-static irqreturn_t gta02kbd_headphone_irq(int irq, void *dev_id);
static irqreturn_t gta02kbd_default_key_irq(int irq, void *dev_id);
@@ -75,10 +64,6 @@ static struct gta02kbd_key keys[] = {
.isr = gta02kbd_default_key_irq,
.input_key = KEY_PAUSE,
},
- [GTA02_KEY_JACK] = {
- .name = "GTA02 Headphone jack",
- .isr = gta02kbd_headphone_irq,
- },
};
/* This timer section filters AUX button IRQ bouncing */
@@ -154,106 +139,6 @@ static irqreturn_t gta02kbd_default_key_irq(int irq, void *dev_id)
return IRQ_HANDLED;
}
-
-static const char *event_array_jack[2][4] = {
- [0] = {
- "SWITCH_NAME=headset",
- "SWITCH_STATE=0",
- "EVENT=remove",
- NULL
- },
- [1] = {
- "SWITCH_NAME=headset",
- "SWITCH_STATE=1",
- "EVENT=insert",
- NULL
- },
-};
-
-static void gta02kbd_jack_event(struct device *dev, int num)
-{
- kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, (char **)event_array_jack[!!num]);
-}
-
-
-static void gta02kbd_debounce_jack(struct work_struct *work)
-{
- struct gta02kbd *kbd = container_of(work, struct gta02kbd, work);
- unsigned long flags;
- int loop = 0;
- int level;
-
- do {
- /*
- * we wait out any multiple interrupt
- * stuttering in 100ms lumps
- */
- do {
- kbd->hp_irq_count_in_work = kbd->hp_irq_count;
- msleep(100);
- } while (kbd->hp_irq_count != kbd->hp_irq_count_in_work);
- /*
- * no new interrupts on jack for 100ms...
- * ok we will report it
- */
- level = gpio_get_value(kbd->pdev->resource[GTA02_KEY_JACK].start);
- input_report_switch(kbd->input, SW_HEADPHONE_INSERT, level);
- input_sync(kbd->input);
- gta02kbd_jack_event(kbd->cdev, level);
- /*
- * we go around the outer loop again if we detect that more
- * interrupts came while we are servicing here. But we have
- * to sequence it carefully with interrupts off
- */
- local_save_flags(flags);
- /* no interrupts during this work means we can exit the work */
- loop = !!(kbd->hp_irq_count != kbd->hp_irq_count_in_work);
- if (!loop)
- kbd->work_in_progress = 0;
- local_irq_restore(flags);
- /*
- * interrupt that comes here will either queue a new work action
- * since work_in_progress is cleared now, or be dealt with
- * when we loop.
- */
- } while (loop);
-}
-
-
-static irqreturn_t gta02kbd_headphone_irq(int irq, void *dev_id)
-{
- struct gta02kbd *gta02kbd_data = dev_id;
-
- /*
- * this interrupt is prone to bouncing and userspace doesn't like
- * to have to deal with that kind of thing. So we do not accept
- * that a jack interrupt is equal to a jack event. Instead we fire
- * some work on the first interrupt, and it hangs about in 100ms units
- * until no more interrupts come. Then it accepts the state it finds
- * for jack insert and reports it once
- */
-
- gta02kbd_data->hp_irq_count++;
- /*
- * the first interrupt we see for a while, we fire the work item
- * and record the interrupt count when we did that. If more interrupts
- * come in the meanwhile, we can tell by the difference in that
- * stored count and hp_irq_count which increments every interrupt
- */
- if (!gta02kbd_data->work_in_progress) {
- gta02kbd_data->jack_irq = irq;
- gta02kbd_data->hp_irq_count_in_work =
- gta02kbd_data->hp_irq_count;
- if (!schedule_work(&gta02kbd_data->work))
- printk(KERN_ERR
- "Unable to schedule headphone debounce\n");
- else
- gta02kbd_data->work_in_progress = 1;
- }
-
- return IRQ_HANDLED;
-}
-
#ifdef CONFIG_PM
static int gta02kbd_suspend(struct platform_device *dev, pm_message_t state)
{
@@ -272,23 +157,6 @@ static int gta02kbd_resume(struct platform_device *dev)
#define gta02kbd_resume NULL
#endif
-static ssize_t gta02kbd_switch_name_show(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- return sprintf(buf, "%s\n", "gta02 Headset Jack");
-}
-
-static ssize_t gta02kbd_switch_state_show(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct gta02kbd *kbd = dev_get_drvdata(dev);
- return sprintf(buf, "%d\n",
- gpio_get_value(kbd->pdev->resource[GTA02_KEY_JACK].start));
-}
-
-static DEVICE_ATTR(name, S_IRUGO , gta02kbd_switch_name_show, NULL);
-static DEVICE_ATTR(state, S_IRUGO , gta02kbd_switch_state_show, NULL);
-
static int gta02kbd_probe(struct platform_device *pdev)
{
struct gta02kbd *gta02kbd;
@@ -297,6 +165,9 @@ static int gta02kbd_probe(struct platform_device *pdev)
int irq;
int n;
+ if (pdev->resource[0].flags != 0)
+ return -EINVAL;
+
gta02kbd = kzalloc(sizeof(struct gta02kbd), GFP_KERNEL);
input_dev = input_allocate_device();
if (!gta02kbd || !input_dev) {
@@ -308,15 +179,10 @@ static int gta02kbd_probe(struct platform_device *pdev)
gta02kbd->pdev = pdev;
timer_kbd = gta02kbd;
- if (pdev->resource[0].flags != 0)
- return -EINVAL;
-
platform_set_drvdata(pdev, gta02kbd);
gta02kbd->input = input_dev;
- INIT_WORK(&gta02kbd->work, gta02kbd_debounce_jack);
-
input_dev->name = "GTA02 Buttons";
input_dev->phys = "gta02kbd/input0";
input_dev->id.bustype = BUS_HOST;
@@ -326,7 +192,6 @@ static int gta02kbd_probe(struct platform_device *pdev)
input_dev->dev.parent = &pdev->dev;
input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_SW);
- set_bit(SW_HEADPHONE_INSERT, input_dev->swbit);
set_bit(KEY_PHONE, input_dev->keybit);
set_bit(KEY_PAUSE, input_dev->keybit);
@@ -334,21 +199,6 @@ static int gta02kbd_probe(struct platform_device *pdev)
if (rc)
goto out_register;
- gta02kbd->cdev = device_create(gta02kbd_switch_class,
- &pdev->dev, 0, gta02kbd, "headset");
- if (unlikely(IS_ERR(gta02kbd->cdev))) {
- rc = PTR_ERR(gta02kbd->cdev);
- goto out_device_create;
- }
-
- rc = device_create_file(gta02kbd->cdev, &dev_attr_name);
- if(rc)
- goto out_device_create_file;
-
- rc = device_create_file(gta02kbd->cdev, &dev_attr_state);
- if(rc)
- goto out_device_create_file;
-
/* register GPIO IRQs */
for(n = 0; n < min(pdev->num_resources, ARRAY_SIZE(keys)); n++) {
@@ -371,18 +221,15 @@ static int gta02kbd_probe(struct platform_device *pdev)
free_irq(gpio_to_irq(pdev->resource[n].start),
gta02kbd);
}
- goto out_device_create_file;
+ goto out_device_create;
}
keys[n].irq = irq;
}
- enable_irq_wake(keys[GTA02_KEY_JACK].irq);
return 0;
-out_device_create_file:
- device_unregister(gta02kbd->cdev);
out_device_create:
input_unregister_device(gta02kbd->input);
out_register:
@@ -397,11 +244,9 @@ static int gta02kbd_remove(struct platform_device *pdev)
{
struct gta02kbd *gta02kbd = platform_get_drvdata(pdev);
- free_irq(gpio_to_irq(pdev->resource[2].start), gta02kbd);
free_irq(gpio_to_irq(pdev->resource[1].start), gta02kbd);
free_irq(gpio_to_irq(pdev->resource[0].start), gta02kbd);
- device_unregister(gta02kbd->cdev);
input_unregister_device(gta02kbd->input);
input_free_device(gta02kbd->input);
platform_set_drvdata(pdev, NULL);
@@ -422,16 +267,12 @@ static struct platform_driver gta02kbd_driver = {
static int __devinit gta02kbd_init(void)
{
- gta02kbd_switch_class = class_create(THIS_MODULE, "switch");
- if (IS_ERR(gta02kbd_switch_class))
- return PTR_ERR(gta02kbd_switch_class);
return platform_driver_register(&gta02kbd_driver);
}
static void __exit gta02kbd_exit(void)
{
platform_driver_unregister(&gta02kbd_driver);
- class_destroy(gta02kbd_switch_class);
}
module_init(gta02kbd_init);
diff --git a/target/linux/s3c24xx/files-2.6.30/sound/soc/s3c24xx/gta02_wm8753.c b/target/linux/s3c24xx/files-2.6.30/sound/soc/s3c24xx/gta02_wm8753.c
index 1f8f9db..e82c60a 100644
--- a/target/linux/s3c24xx/files-2.6.30/sound/soc/s3c24xx/gta02_wm8753.c
+++ b/target/linux/s3c24xx/files-2.6.30/sound/soc/s3c24xx/gta02_wm8753.c
@@ -22,6 +22,7 @@
#include <sound/pcm.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
+#include <sound/jack.h>
#include <asm/mach-types.h>
@@ -38,6 +39,7 @@
#include "s3c24xx-i2s.h"
static struct snd_soc_card neo1973_gta02;
+static struct snd_soc_jack gta02_hs_jack;
static int neo1973_gta02_hifi_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
@@ -332,6 +334,27 @@ static const struct snd_kcontrol_new wm8753_neo1973_gta02_controls[] = {
lm4853_set_spk),
};
+static struct snd_soc_jack_pin gta02_hs_jack_pins[] = {
+ {
+ .pin = "Headset Mic",
+ .mask = SND_JACK_MICROPHONE
+ },
+ {
+ .pin = "Stereo Out",
+ .mask = SND_JACK_HEADPHONE,
+ .invert = 1,
+ },
+};
+
+static struct snd_soc_jack_gpio gta02_hs_jack_gpios[] = {
+ {
+ .gpio = GTA02_GPIO_JACK_INSERT,
+ .name = "headset-gpio",
+ .report = SND_JACK_HEADSET,
+ .debounce_time = 100,
+ },
+};
+
/*
* This is an example machine initialisation for a wm8753 connected to a
* neo1973 GTA02.
@@ -370,6 +393,28 @@ static int neo1973_gta02_wm8753_init(struct snd_soc_codec *codec)
snd_soc_dapm_sync(codec);
+ err = snd_soc_jack_new(&neo1973_gta02, "Headset Jack",
+ SND_JACK_HEADSET, &gta02_hs_jack);
+ if (err) {
+ dev_err(codec->card->dev, "failed to alloc headset jack\n");
+ return err;
+ }
+
+ err = snd_soc_jack_add_pins(&gta02_hs_jack, ARRAY_SIZE(gta02_hs_jack_pins),
+ gta02_hs_jack_pins);
+ if (err) {
+ dev_err(codec->card->dev, "failed to add headset jack pins\n");
+ return err;
+ }
+
+ err = snd_soc_jack_add_gpios(&gta02_hs_jack, ARRAY_SIZE(gta02_hs_jack_gpios),
+ gta02_hs_jack_gpios);
+ if (err) {
+ dev_err(codec->card->dev, "failed to add headset jack gpios\n");
+ return err;
+ }
+
+
return 0;
}
@@ -423,6 +468,7 @@ static struct snd_soc_device neo1973_gta02_snd_devdata = {
static struct platform_device *neo1973_gta02_snd_device;
+
static int __init neo1973_gta02_init(void)
{
int ret;
@@ -439,8 +485,10 @@ static int __init neo1973_gta02_init(void)
return ret;
neo1973_gta02_snd_device = platform_device_alloc("soc-audio", -1);
- if (!neo1973_gta02_snd_device)
- return -ENOMEM;
+ if (!neo1973_gta02_snd_device) {
+ ret = -ENOMEM;
+ goto err_unregister_dai;
+ }
platform_set_drvdata(neo1973_gta02_snd_device,
&neo1973_gta02_snd_devdata);
@@ -449,7 +497,7 @@ static int __init neo1973_gta02_init(void)
if (ret) {
platform_device_put(neo1973_gta02_snd_device);
- return ret;
+ goto err_unregister_dai;
}
/* Initialise GPIOs used by amp */
@@ -462,13 +510,21 @@ static int __init neo1973_gta02_init(void)
/* Speaker off by default */
s3c2410_gpio_setpin(GTA02_GPIO_HP_IN, 1);
- return ret;
+
+ return 0;
+
+err_unregister_dai:
+ snd_soc_unregister_dai(&bt_dai);
+ return ret;
}
module_init(neo1973_gta02_init);
static void __exit neo1973_gta02_exit(void)
{
snd_soc_unregister_dai(&bt_dai);
+ snd_soc_jack_free_gpios(&gta02_hs_jack, ARRAY_SIZE(gta02_hs_jack_gpios),
+ gta02_hs_jack_gpios);
+
platform_device_unregister(neo1973_gta02_snd_device);
}
module_exit(neo1973_gta02_exit);