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
5bb93a33
Commit
5bb93a33
authored
Mar 28, 2018
by
Mark Brown
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'asoc/topic/pcm186x' into asoc-next
parents
8f7b85a7
c044cfda
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
92 deletions
+68
-92
sound/soc/codecs/pcm186x-i2c.c
sound/soc/codecs/pcm186x-i2c.c
+0
-8
sound/soc/codecs/pcm186x-spi.c
sound/soc/codecs/pcm186x-spi.c
+0
-8
sound/soc/codecs/pcm186x.c
sound/soc/codecs/pcm186x.c
+68
-75
sound/soc/codecs/pcm186x.h
sound/soc/codecs/pcm186x.h
+0
-1
No files found.
sound/soc/codecs/pcm186x-i2c.c
View file @
5bb93a33
...
...
@@ -36,13 +36,6 @@ static int pcm186x_i2c_probe(struct i2c_client *i2c,
return
pcm186x_probe
(
&
i2c
->
dev
,
type
,
irq
,
regmap
);
}
static
int
pcm186x_i2c_remove
(
struct
i2c_client
*
i2c
)
{
pcm186x_remove
(
&
i2c
->
dev
);
return
0
;
}
static
const
struct
i2c_device_id
pcm186x_i2c_id
[]
=
{
{
"pcm1862"
,
PCM1862
},
{
"pcm1863"
,
PCM1863
},
...
...
@@ -54,7 +47,6 @@ MODULE_DEVICE_TABLE(i2c, pcm186x_i2c_id);
static
struct
i2c_driver
pcm186x_i2c_driver
=
{
.
probe
=
pcm186x_i2c_probe
,
.
remove
=
pcm186x_i2c_remove
,
.
id_table
=
pcm186x_i2c_id
,
.
driver
=
{
.
name
=
"pcm186x"
,
...
...
sound/soc/codecs/pcm186x-spi.c
View file @
5bb93a33
...
...
@@ -36,13 +36,6 @@ static int pcm186x_spi_probe(struct spi_device *spi)
return
pcm186x_probe
(
&
spi
->
dev
,
type
,
irq
,
regmap
);
}
static
int
pcm186x_spi_remove
(
struct
spi_device
*
spi
)
{
pcm186x_remove
(
&
spi
->
dev
);
return
0
;
}
static
const
struct
spi_device_id
pcm186x_spi_id
[]
=
{
{
"pcm1862"
,
PCM1862
},
{
"pcm1863"
,
PCM1863
},
...
...
@@ -54,7 +47,6 @@ MODULE_DEVICE_TABLE(spi, pcm186x_spi_id);
static
struct
spi_driver
pcm186x_spi_driver
=
{
.
probe
=
pcm186x_spi_probe
,
.
remove
=
pcm186x_spi_remove
,
.
id_table
=
pcm186x_spi_id
,
.
driver
=
{
.
name
=
"pcm186x"
,
...
...
sound/soc/codecs/pcm186x.c
View file @
5bb93a33
...
...
@@ -262,9 +262,8 @@ static int pcm186x_hw_params(struct snd_pcm_substream *substream,
struct
snd_pcm_hw_params
*
params
,
struct
snd_soc_dai
*
dai
)
{
struct
snd_soc_codec
*
codec
=
dai
->
codec
;
struct
pcm186x_priv
*
priv
=
snd_soc_codec_get_drvdata
(
codec
);
struct
snd_soc_component
*
component
=
dai
->
component
;
struct
pcm186x_priv
*
priv
=
snd_soc_component_get_drvdata
(
component
);
unsigned
int
rate
=
params_rate
(
params
);
unsigned
int
format
=
params_format
(
params
);
unsigned
int
width
=
params_width
(
params
);
...
...
@@ -274,7 +273,7 @@ static int pcm186x_hw_params(struct snd_pcm_substream *substream,
u8
tdm_tx_sel
=
0
;
u8
pcm_cfg
=
0
;
dev_dbg
(
co
dec
->
dev
,
"%s() rate=%u format=0x%x width=%u channels=%u
\n
"
,
dev_dbg
(
co
mponent
->
dev
,
"%s() rate=%u format=0x%x width=%u channels=%u
\n
"
,
__func__
,
rate
,
format
,
width
,
channels
);
switch
(
width
)
{
...
...
@@ -306,7 +305,7 @@ static int pcm186x_hw_params(struct snd_pcm_substream *substream,
return
-
EINVAL
;
}
snd_soc_
update_bits
(
codec
,
PCM186X_PCM_CFG
,
snd_soc_
component_update_bits
(
component
,
PCM186X_PCM_CFG
,
PCM186X_PCM_CFG_RX_WLEN_MASK
|
PCM186X_PCM_CFG_TX_WLEN_MASK
,
pcm_cfg
);
...
...
@@ -329,14 +328,14 @@ static int pcm186x_hw_params(struct snd_pcm_substream *substream,
return
-
EINVAL
;
}
snd_soc_
update_bits
(
codec
,
PCM186X_TDM_TX_SEL
,
snd_soc_
component_update_bits
(
component
,
PCM186X_TDM_TX_SEL
,
PCM186X_TDM_TX_SEL_MASK
,
tdm_tx_sel
);
/* In DSP/TDM mode, the LRCLK divider must be 256 */
div_lrck
=
256
;
/* Configure 1/256 duty cycle for LRCK */
snd_soc_
update_bits
(
codec
,
PCM186X_PCM_CFG
,
snd_soc_
component_update_bits
(
component
,
PCM186X_PCM_CFG
,
PCM186X_PCM_CFG_TDM_LRCK_MODE
,
PCM186X_PCM_CFG_TDM_LRCK_MODE
);
}
...
...
@@ -345,12 +344,12 @@ static int pcm186x_hw_params(struct snd_pcm_substream *substream,
if
(
priv
->
is_master_mode
)
{
div_bck
=
priv
->
sysclk
/
(
div_lrck
*
rate
);
dev_dbg
(
co
dec
->
dev
,
dev_dbg
(
co
mponent
->
dev
,
"%s() master_clk=%u div_bck=%u div_lrck=%u
\n
"
,
__func__
,
priv
->
sysclk
,
div_bck
,
div_lrck
);
snd_soc_
write
(
codec
,
PCM186X_BCK_DIV
,
div_bck
-
1
);
snd_soc_
write
(
codec
,
PCM186X_LRK_DIV
,
div_lrck
-
1
);
snd_soc_
component_write
(
component
,
PCM186X_BCK_DIV
,
div_bck
-
1
);
snd_soc_
component_write
(
component
,
PCM186X_LRK_DIV
,
div_lrck
-
1
);
}
return
0
;
...
...
@@ -358,18 +357,18 @@ static int pcm186x_hw_params(struct snd_pcm_substream *substream,
static
int
pcm186x_set_fmt
(
struct
snd_soc_dai
*
dai
,
unsigned
int
format
)
{
struct
snd_soc_co
dec
*
codec
=
dai
->
codec
;
struct
pcm186x_priv
*
priv
=
snd_soc_co
dec_get_drvdata
(
codec
);
struct
snd_soc_co
mponent
*
component
=
dai
->
component
;
struct
pcm186x_priv
*
priv
=
snd_soc_co
mponent_get_drvdata
(
component
);
u8
clk_ctrl
=
0
;
u8
pcm_cfg
=
0
;
dev_dbg
(
co
dec
->
dev
,
"%s() format=0x%x
\n
"
,
__func__
,
format
);
dev_dbg
(
co
mponent
->
dev
,
"%s() format=0x%x
\n
"
,
__func__
,
format
);
/* set master/slave audio interface */
switch
(
format
&
SND_SOC_DAIFMT_MASTER_MASK
)
{
case
SND_SOC_DAIFMT_CBM_CFM
:
if
(
!
priv
->
sysclk
)
{
dev_err
(
co
dec
->
dev
,
"operating in master mode requires sysclock to be configured
\n
"
);
dev_err
(
co
mponent
->
dev
,
"operating in master mode requires sysclock to be configured
\n
"
);
return
-
EINVAL
;
}
clk_ctrl
|=
PCM186X_CLK_CTRL_MST_MODE
;
...
...
@@ -379,7 +378,7 @@ static int pcm186x_set_fmt(struct snd_soc_dai *dai, unsigned int format)
priv
->
is_master_mode
=
false
;
break
;
default:
dev_err
(
co
dec
->
dev
,
"Invalid DAI master/slave interface
\n
"
);
dev_err
(
co
mponent
->
dev
,
"Invalid DAI master/slave interface
\n
"
);
return
-
EINVAL
;
}
...
...
@@ -388,7 +387,7 @@ static int pcm186x_set_fmt(struct snd_soc_dai *dai, unsigned int format)
case
SND_SOC_DAIFMT_NB_NF
:
break
;
default:
dev_err
(
co
dec
->
dev
,
"Inverted DAI clocks not supported
\n
"
);
dev_err
(
co
mponent
->
dev
,
"Inverted DAI clocks not supported
\n
"
);
return
-
EINVAL
;
}
...
...
@@ -410,16 +409,16 @@ static int pcm186x_set_fmt(struct snd_soc_dai *dai, unsigned int format)
pcm_cfg
=
PCM186X_PCM_CFG_FMT_TDM
;
break
;
default:
dev_err
(
co
dec
->
dev
,
"Invalid DAI format
\n
"
);
dev_err
(
co
mponent
->
dev
,
"Invalid DAI format
\n
"
);
return
-
EINVAL
;
}
snd_soc_
update_bits
(
codec
,
PCM186X_CLK_CTRL
,
snd_soc_
component_update_bits
(
component
,
PCM186X_CLK_CTRL
,
PCM186X_CLK_CTRL_MST_MODE
,
clk_ctrl
);
snd_soc_
write
(
codec
,
PCM186X_TDM_TX_OFFSET
,
priv
->
tdm_offset
);
snd_soc_
component_write
(
component
,
PCM186X_TDM_TX_OFFSET
,
priv
->
tdm_offset
);
snd_soc_
update_bits
(
codec
,
PCM186X_PCM_CFG
,
snd_soc_
component_update_bits
(
component
,
PCM186X_PCM_CFG
,
PCM186X_PCM_CFG_FMT_MASK
,
pcm_cfg
);
return
0
;
...
...
@@ -428,16 +427,16 @@ static int pcm186x_set_fmt(struct snd_soc_dai *dai, unsigned int format)
static
int
pcm186x_set_tdm_slot
(
struct
snd_soc_dai
*
dai
,
unsigned
int
tx_mask
,
unsigned
int
rx_mask
,
int
slots
,
int
slot_width
)
{
struct
snd_soc_co
dec
*
codec
=
dai
->
codec
;
struct
pcm186x_priv
*
priv
=
snd_soc_co
dec_get_drvdata
(
codec
);
struct
snd_soc_co
mponent
*
component
=
dai
->
component
;
struct
pcm186x_priv
*
priv
=
snd_soc_co
mponent_get_drvdata
(
component
);
unsigned
int
first_slot
,
last_slot
,
tdm_offset
;
dev_dbg
(
co
dec
->
dev
,
dev_dbg
(
co
mponent
->
dev
,
"%s() tx_mask=0x%x rx_mask=0x%x slots=%d slot_width=%d
\n
"
,
__func__
,
tx_mask
,
rx_mask
,
slots
,
slot_width
);
if
(
!
tx_mask
)
{
dev_err
(
co
dec
->
dev
,
"tdm tx mask must not be 0
\n
"
);
dev_err
(
co
mponent
->
dev
,
"tdm tx mask must not be 0
\n
"
);
return
-
EINVAL
;
}
...
...
@@ -445,14 +444,14 @@ static int pcm186x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
last_slot
=
__fls
(
tx_mask
);
if
(
last_slot
-
first_slot
!=
hweight32
(
tx_mask
)
-
1
)
{
dev_err
(
co
dec
->
dev
,
"tdm tx mask must be contiguous
\n
"
);
dev_err
(
co
mponent
->
dev
,
"tdm tx mask must be contiguous
\n
"
);
return
-
EINVAL
;
}
tdm_offset
=
first_slot
*
slot_width
;
if
(
tdm_offset
>
255
)
{
dev_err
(
co
dec
->
dev
,
"tdm tx slot selection out of bounds
\n
"
);
dev_err
(
co
mponent
->
dev
,
"tdm tx slot selection out of bounds
\n
"
);
return
-
EINVAL
;
}
...
...
@@ -464,10 +463,10 @@ static int pcm186x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
static
int
pcm186x_set_dai_sysclk
(
struct
snd_soc_dai
*
dai
,
int
clk_id
,
unsigned
int
freq
,
int
dir
)
{
struct
snd_soc_co
dec
*
codec
=
dai
->
codec
;
struct
pcm186x_priv
*
priv
=
snd_soc_co
dec_get_drvdata
(
codec
);
struct
snd_soc_co
mponent
*
component
=
dai
->
component
;
struct
pcm186x_priv
*
priv
=
snd_soc_co
mponent_get_drvdata
(
component
);
dev_dbg
(
co
dec
->
dev
,
"%s() clk_id=%d freq=%u dir=%d
\n
"
,
dev_dbg
(
co
mponent
->
dev
,
"%s() clk_id=%d freq=%u dir=%d
\n
"
,
__func__
,
clk_id
,
freq
,
dir
);
priv
->
sysclk
=
freq
;
...
...
@@ -506,9 +505,9 @@ static struct snd_soc_dai_driver pcm1865_dai = {
.
ops
=
&
pcm186x_dai_ops
,
};
static
int
pcm186x_power_on
(
struct
snd_soc_co
dec
*
codec
)
static
int
pcm186x_power_on
(
struct
snd_soc_co
mponent
*
component
)
{
struct
pcm186x_priv
*
priv
=
snd_soc_co
dec_get_drvdata
(
codec
);
struct
pcm186x_priv
*
priv
=
snd_soc_co
mponent_get_drvdata
(
component
);
int
ret
=
0
;
ret
=
regulator_bulk_enable
(
ARRAY_SIZE
(
priv
->
supplies
),
...
...
@@ -519,25 +518,25 @@ static int pcm186x_power_on(struct snd_soc_codec *codec)
regcache_cache_only
(
priv
->
regmap
,
false
);
ret
=
regcache_sync
(
priv
->
regmap
);
if
(
ret
)
{
dev_err
(
co
dec
->
dev
,
"Failed to restore cache
\n
"
);
dev_err
(
co
mponent
->
dev
,
"Failed to restore cache
\n
"
);
regcache_cache_only
(
priv
->
regmap
,
true
);
regulator_bulk_disable
(
ARRAY_SIZE
(
priv
->
supplies
),
priv
->
supplies
);
return
ret
;
}
snd_soc_
update_bits
(
codec
,
PCM186X_POWER_CTRL
,
snd_soc_
component_update_bits
(
component
,
PCM186X_POWER_CTRL
,
PCM186X_PWR_CTRL_PWRDN
,
0
);
return
0
;
}
static
int
pcm186x_power_off
(
struct
snd_soc_co
dec
*
codec
)
static
int
pcm186x_power_off
(
struct
snd_soc_co
mponent
*
component
)
{
struct
pcm186x_priv
*
priv
=
snd_soc_co
dec_get_drvdata
(
codec
);
struct
pcm186x_priv
*
priv
=
snd_soc_co
mponent_get_drvdata
(
component
);
int
ret
;
snd_soc_
update_bits
(
codec
,
PCM186X_POWER_CTRL
,
snd_soc_
component_update_bits
(
component
,
PCM186X_POWER_CTRL
,
PCM186X_PWR_CTRL_PWRDN
,
PCM186X_PWR_CTRL_PWRDN
);
regcache_cache_only
(
priv
->
regmap
,
true
);
...
...
@@ -550,11 +549,11 @@ static int pcm186x_power_off(struct snd_soc_codec *codec)
return
0
;
}
static
int
pcm186x_set_bias_level
(
struct
snd_soc_co
dec
*
codec
,
static
int
pcm186x_set_bias_level
(
struct
snd_soc_co
mponent
*
component
,
enum
snd_soc_bias_level
level
)
{
dev_dbg
(
co
dec
->
dev
,
"## %s: %d -> %d
\n
"
,
__func__
,
snd_soc_co
dec_get_bias_level
(
codec
),
level
);
dev_dbg
(
co
mponent
->
dev
,
"## %s: %d -> %d
\n
"
,
__func__
,
snd_soc_co
mponent_get_bias_level
(
component
),
level
);
switch
(
level
)
{
case
SND_SOC_BIAS_ON
:
...
...
@@ -562,42 +561,44 @@ static int pcm186x_set_bias_level(struct snd_soc_codec *codec,
case
SND_SOC_BIAS_PREPARE
:
break
;
case
SND_SOC_BIAS_STANDBY
:
if
(
snd_soc_co
dec_get_bias_level
(
codec
)
==
SND_SOC_BIAS_OFF
)
pcm186x_power_on
(
co
dec
);
if
(
snd_soc_co
mponent_get_bias_level
(
component
)
==
SND_SOC_BIAS_OFF
)
pcm186x_power_on
(
co
mponent
);
break
;
case
SND_SOC_BIAS_OFF
:
pcm186x_power_off
(
co
dec
);
pcm186x_power_off
(
co
mponent
);
break
;
}
return
0
;
}
static
struct
snd_soc_codec_driver
soc_codec_dev_pcm1863
=
{
.
set_bias_level
=
pcm186x_set_bias_level
,
.
component_driver
=
{
.
controls
=
pcm1863_snd_controls
,
.
num_controls
=
ARRAY_SIZE
(
pcm1863_snd_controls
),
.
dapm_widgets
=
pcm1863_dapm_widgets
,
.
num_dapm_widgets
=
ARRAY_SIZE
(
pcm1863_dapm_widgets
),
.
dapm_routes
=
pcm1863_dapm_routes
,
.
num_dapm_routes
=
ARRAY_SIZE
(
pcm1863_dapm_routes
),
},
static
struct
snd_soc_component_driver
soc_codec_dev_pcm1863
=
{
.
set_bias_level
=
pcm186x_set_bias_level
,
.
controls
=
pcm1863_snd_controls
,
.
num_controls
=
ARRAY_SIZE
(
pcm1863_snd_controls
),
.
dapm_widgets
=
pcm1863_dapm_widgets
,
.
num_dapm_widgets
=
ARRAY_SIZE
(
pcm1863_dapm_widgets
),
.
dapm_routes
=
pcm1863_dapm_routes
,
.
num_dapm_routes
=
ARRAY_SIZE
(
pcm1863_dapm_routes
),
.
idle_bias_on
=
1
,
.
use_pmdown_time
=
1
,
.
endianness
=
1
,
.
non_legacy_dai_naming
=
1
,
};
static
struct
snd_soc_codec_driver
soc_codec_dev_pcm1865
=
{
.
set_bias_level
=
pcm186x_set_bias_level
,
.
suspend_bias_off
=
true
,
.
component_driver
=
{
.
controls
=
pcm1865_snd_controls
,
.
num_controls
=
ARRAY_SIZE
(
pcm1865_snd_controls
),
.
dapm_widgets
=
pcm1865_dapm_widgets
,
.
num_dapm_widgets
=
ARRAY_SIZE
(
pcm1865_dapm_widgets
),
.
dapm_routes
=
pcm1865_dapm_routes
,
.
num_dapm_routes
=
ARRAY_SIZE
(
pcm1865_dapm_routes
),
},
static
struct
snd_soc_component_driver
soc_codec_dev_pcm1865
=
{
.
set_bias_level
=
pcm186x_set_bias_level
,
.
controls
=
pcm1865_snd_controls
,
.
num_controls
=
ARRAY_SIZE
(
pcm1865_snd_controls
),
.
dapm_widgets
=
pcm1865_dapm_widgets
,
.
num_dapm_widgets
=
ARRAY_SIZE
(
pcm1865_dapm_widgets
),
.
dapm_routes
=
pcm1865_dapm_routes
,
.
num_dapm_routes
=
ARRAY_SIZE
(
pcm1865_dapm_routes
),
.
suspend_bias_off
=
1
,
.
idle_bias_on
=
1
,
.
use_pmdown_time
=
1
,
.
endianness
=
1
,
.
non_legacy_dai_naming
=
1
,
};
static
bool
pcm186x_volatile
(
struct
device
*
dev
,
unsigned
int
reg
)
...
...
@@ -687,13 +688,13 @@ int pcm186x_probe(struct device *dev, enum pcm186x_type type, int irq,
switch
(
type
)
{
case
PCM1865
:
case
PCM1864
:
ret
=
snd_soc_register_codec
(
dev
,
&
soc_codec_dev_pcm1865
,
ret
=
devm_snd_soc_register_component
(
dev
,
&
soc_codec_dev_pcm1865
,
&
pcm1865_dai
,
1
);
break
;
case
PCM1863
:
case
PCM1862
:
default:
ret
=
snd_soc_register_codec
(
dev
,
&
soc_codec_dev_pcm1863
,
ret
=
devm_snd_soc_register_component
(
dev
,
&
soc_codec_dev_pcm1863
,
&
pcm1863_dai
,
1
);
}
if
(
ret
)
{
...
...
@@ -705,14 +706,6 @@ int pcm186x_probe(struct device *dev, enum pcm186x_type type, int irq,
}
EXPORT_SYMBOL_GPL
(
pcm186x_probe
);
int
pcm186x_remove
(
struct
device
*
dev
)
{
snd_soc_unregister_codec
(
dev
);
return
0
;
}
EXPORT_SYMBOL_GPL
(
pcm186x_remove
);
MODULE_AUTHOR
(
"Andreas Dannenberg <dannenberg@ti.com>"
);
MODULE_AUTHOR
(
"Andrew F. Davis <afd@ti.com>"
);
MODULE_DESCRIPTION
(
"PCM186x Universal Audio ADC driver"
);
...
...
sound/soc/codecs/pcm186x.h
View file @
5bb93a33
...
...
@@ -215,6 +215,5 @@ extern const struct regmap_config pcm186x_regmap;
int
pcm186x_probe
(
struct
device
*
dev
,
enum
pcm186x_type
type
,
int
irq
,
struct
regmap
*
regmap
);
int
pcm186x_remove
(
struct
device
*
dev
);
#endif
/* _PCM186X_H_ */
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