Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
a6ba2b2d
Commit
a6ba2b2d
authored
Jan 08, 2009
by
Mark Brown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ASoC: Implement WM8350 headphone jack detection
Signed-off-by:
Mark Brown
<
broonie@opensource.wolfsonmicro.com
>
parent
8a2cd618
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
125 additions
and
0 deletions
+125
-0
include/linux/mfd/wm8350/audio.h
include/linux/mfd/wm8350/audio.h
+1
-0
sound/soc/codecs/wm8350.c
sound/soc/codecs/wm8350.c
+116
-0
sound/soc/codecs/wm8350.h
sound/soc/codecs/wm8350.h
+8
-0
No files found.
include/linux/mfd/wm8350/audio.h
View file @
a6ba2b2d
...
@@ -490,6 +490,7 @@
...
@@ -490,6 +490,7 @@
/*
/*
* R231 (0xE7) - Jack Status
* R231 (0xE7) - Jack Status
*/
*/
#define WM8350_JACK_L_LVL 0x0800
#define WM8350_JACK_R_LVL 0x0400
#define WM8350_JACK_R_LVL 0x0400
/*
/*
...
...
sound/soc/codecs/wm8350.c
View file @
a6ba2b2d
...
@@ -51,10 +51,17 @@ struct wm8350_output {
...
@@ -51,10 +51,17 @@ struct wm8350_output {
u16
mute
;
u16
mute
;
};
};
struct
wm8350_jack_data
{
struct
snd_soc_jack
*
jack
;
int
report
;
};
struct
wm8350_data
{
struct
wm8350_data
{
struct
snd_soc_codec
codec
;
struct
snd_soc_codec
codec
;
struct
wm8350_output
out1
;
struct
wm8350_output
out1
;
struct
wm8350_output
out2
;
struct
wm8350_output
out2
;
struct
wm8350_jack_data
hpl
;
struct
wm8350_jack_data
hpr
;
struct
regulator_bulk_data
supplies
[
ARRAY_SIZE
(
supply_names
)];
struct
regulator_bulk_data
supplies
[
ARRAY_SIZE
(
supply_names
)];
};
};
...
@@ -1328,6 +1335,95 @@ static int wm8350_resume(struct platform_device *pdev)
...
@@ -1328,6 +1335,95 @@ static int wm8350_resume(struct platform_device *pdev)
return
0
;
return
0
;
}
}
static
void
wm8350_hp_jack_handler
(
struct
wm8350
*
wm8350
,
int
irq
,
void
*
data
)
{
struct
wm8350_data
*
priv
=
data
;
u16
reg
;
int
report
;
int
mask
;
struct
wm8350_jack_data
*
jack
=
NULL
;
switch
(
irq
)
{
case
WM8350_IRQ_CODEC_JCK_DET_L
:
jack
=
&
priv
->
hpl
;
mask
=
WM8350_JACK_L_LVL
;
break
;
case
WM8350_IRQ_CODEC_JCK_DET_R
:
jack
=
&
priv
->
hpr
;
mask
=
WM8350_JACK_R_LVL
;
break
;
default:
BUG
();
}
if
(
!
jack
->
jack
)
{
dev_warn
(
wm8350
->
dev
,
"Jack interrupt called with no jack
\n
"
);
return
;
}
/* Debounce */
msleep
(
200
);
reg
=
wm8350_reg_read
(
wm8350
,
WM8350_JACK_PIN_STATUS
);
if
(
reg
&
mask
)
report
=
jack
->
report
;
else
report
=
0
;
snd_soc_jack_report
(
jack
->
jack
,
report
,
jack
->
report
);
}
/**
* wm8350_hp_jack_detect - Enable headphone jack detection.
*
* @codec: WM8350 codec
* @which: left or right jack detect signal
* @jack: jack to report detection events on
* @report: value to report
*
* Enables the headphone jack detection of the WM8350.
*/
int
wm8350_hp_jack_detect
(
struct
snd_soc_codec
*
codec
,
enum
wm8350_jack
which
,
struct
snd_soc_jack
*
jack
,
int
report
)
{
struct
wm8350_data
*
priv
=
codec
->
private_data
;
struct
wm8350
*
wm8350
=
codec
->
control_data
;
int
irq
;
int
ena
;
switch
(
which
)
{
case
WM8350_JDL
:
priv
->
hpl
.
jack
=
jack
;
priv
->
hpl
.
report
=
report
;
irq
=
WM8350_IRQ_CODEC_JCK_DET_L
;
ena
=
WM8350_JDL_ENA
;
break
;
case
WM8350_JDR
:
priv
->
hpr
.
jack
=
jack
;
priv
->
hpr
.
report
=
report
;
irq
=
WM8350_IRQ_CODEC_JCK_DET_R
;
ena
=
WM8350_JDR_ENA
;
break
;
default:
return
-
EINVAL
;
}
wm8350_set_bits
(
wm8350
,
WM8350_POWER_MGMT_4
,
WM8350_TOCLK_ENA
);
wm8350_set_bits
(
wm8350
,
WM8350_JACK_DETECT
,
ena
);
/* Sync status */
wm8350_hp_jack_handler
(
wm8350
,
irq
,
priv
);
wm8350_unmask_irq
(
wm8350
,
irq
);
return
0
;
}
EXPORT_SYMBOL_GPL
(
wm8350_hp_jack_detect
);
static
struct
snd_soc_codec
*
wm8350_codec
;
static
struct
snd_soc_codec
*
wm8350_codec
;
static
int
wm8350_probe
(
struct
platform_device
*
pdev
)
static
int
wm8350_probe
(
struct
platform_device
*
pdev
)
...
@@ -1381,6 +1477,13 @@ static int wm8350_probe(struct platform_device *pdev)
...
@@ -1381,6 +1477,13 @@ static int wm8350_probe(struct platform_device *pdev)
wm8350_set_bits
(
wm8350
,
WM8350_ROUT2_VOLUME
,
wm8350_set_bits
(
wm8350
,
WM8350_ROUT2_VOLUME
,
WM8350_OUT2_VU
|
WM8350_OUT2R_MUTE
);
WM8350_OUT2_VU
|
WM8350_OUT2R_MUTE
);
wm8350_mask_irq
(
wm8350
,
WM8350_IRQ_CODEC_JCK_DET_L
);
wm8350_mask_irq
(
wm8350
,
WM8350_IRQ_CODEC_JCK_DET_R
);
wm8350_register_irq
(
wm8350
,
WM8350_IRQ_CODEC_JCK_DET_L
,
wm8350_hp_jack_handler
,
priv
);
wm8350_register_irq
(
wm8350
,
WM8350_IRQ_CODEC_JCK_DET_R
,
wm8350_hp_jack_handler
,
priv
);
ret
=
snd_soc_new_pcms
(
socdev
,
SNDRV_DEFAULT_IDX1
,
SNDRV_DEFAULT_STR1
);
ret
=
snd_soc_new_pcms
(
socdev
,
SNDRV_DEFAULT_IDX1
,
SNDRV_DEFAULT_STR1
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
dev_err
(
&
pdev
->
dev
,
"failed to create pcms
\n
"
);
dev_err
(
&
pdev
->
dev
,
"failed to create pcms
\n
"
);
...
@@ -1411,8 +1514,21 @@ static int wm8350_remove(struct platform_device *pdev)
...
@@ -1411,8 +1514,21 @@ static int wm8350_remove(struct platform_device *pdev)
struct
snd_soc_device
*
socdev
=
platform_get_drvdata
(
pdev
);
struct
snd_soc_device
*
socdev
=
platform_get_drvdata
(
pdev
);
struct
snd_soc_codec
*
codec
=
socdev
->
codec
;
struct
snd_soc_codec
*
codec
=
socdev
->
codec
;
struct
wm8350
*
wm8350
=
codec
->
control_data
;
struct
wm8350
*
wm8350
=
codec
->
control_data
;
struct
wm8350_data
*
priv
=
codec
->
private_data
;
int
ret
;
int
ret
;
wm8350_clear_bits
(
wm8350
,
WM8350_JACK_DETECT
,
WM8350_JDL_ENA
|
WM8350_JDR_ENA
);
wm8350_clear_bits
(
wm8350
,
WM8350_POWER_MGMT_4
,
WM8350_TOCLK_ENA
);
wm8350_mask_irq
(
wm8350
,
WM8350_IRQ_CODEC_JCK_DET_L
);
wm8350_mask_irq
(
wm8350
,
WM8350_IRQ_CODEC_JCK_DET_R
);
wm8350_free_irq
(
wm8350
,
WM8350_IRQ_CODEC_JCK_DET_L
);
wm8350_free_irq
(
wm8350
,
WM8350_IRQ_CODEC_JCK_DET_R
);
priv
->
hpl
.
jack
=
NULL
;
priv
->
hpr
.
jack
=
NULL
;
/* cancel any work waiting to be queued. */
/* cancel any work waiting to be queued. */
ret
=
cancel_delayed_work
(
&
codec
->
delayed_work
);
ret
=
cancel_delayed_work
(
&
codec
->
delayed_work
);
...
...
sound/soc/codecs/wm8350.h
View file @
a6ba2b2d
...
@@ -17,4 +17,12 @@
...
@@ -17,4 +17,12 @@
extern
struct
snd_soc_dai
wm8350_dai
;
extern
struct
snd_soc_dai
wm8350_dai
;
extern
struct
snd_soc_codec_device
soc_codec_dev_wm8350
;
extern
struct
snd_soc_codec_device
soc_codec_dev_wm8350
;
enum
wm8350_jack
{
WM8350_JDL
=
1
,
WM8350_JDR
=
2
,
};
int
wm8350_hp_jack_detect
(
struct
snd_soc_codec
*
codec
,
enum
wm8350_jack
which
,
struct
snd_soc_jack
*
jack
,
int
report
);
#endif
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment