mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
soundwire: cadence_master: improve PDI allocation
PDI number should match dai->id, there is no need to track if a PDI is allocated or not. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20190916192348.467-7-pierre-louis.bossart@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
parent
807c15bc77
commit
1b53385e79
3 changed files with 17 additions and 19 deletions
|
@ -814,7 +814,6 @@ static int cdns_allocate_pdi(struct sdw_cdns *cdns,
|
||||||
|
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
pdi[i].num = i + pdi_offset;
|
pdi[i].num = i + pdi_offset;
|
||||||
pdi[i].assigned = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*stream = pdi;
|
*stream = pdi;
|
||||||
|
@ -1166,21 +1165,20 @@ EXPORT_SYMBOL(cdns_set_sdw_stream);
|
||||||
* @num: Number of PDIs
|
* @num: Number of PDIs
|
||||||
* @pdi: PDI instances
|
* @pdi: PDI instances
|
||||||
*
|
*
|
||||||
* Find and return a free PDI for a given PDI array
|
* Find a PDI for a given PDI array. The PDI num and dai_id are
|
||||||
|
* expected to match, return NULL otherwise.
|
||||||
*/
|
*/
|
||||||
static struct sdw_cdns_pdi *cdns_find_pdi(struct sdw_cdns *cdns,
|
static struct sdw_cdns_pdi *cdns_find_pdi(struct sdw_cdns *cdns,
|
||||||
unsigned int offset,
|
unsigned int offset,
|
||||||
unsigned int num,
|
unsigned int num,
|
||||||
struct sdw_cdns_pdi *pdi)
|
struct sdw_cdns_pdi *pdi,
|
||||||
|
int dai_id)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = offset; i < num; i++) {
|
for (i = offset; i < offset + num; i++)
|
||||||
if (pdi[i].assigned)
|
if (pdi[i].num == dai_id)
|
||||||
continue;
|
return &pdi[i];
|
||||||
pdi[i].assigned = true;
|
|
||||||
return &pdi[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1220,18 +1218,21 @@ EXPORT_SYMBOL(sdw_cdns_config_stream);
|
||||||
*/
|
*/
|
||||||
struct sdw_cdns_pdi *sdw_cdns_alloc_pdi(struct sdw_cdns *cdns,
|
struct sdw_cdns_pdi *sdw_cdns_alloc_pdi(struct sdw_cdns *cdns,
|
||||||
struct sdw_cdns_streams *stream,
|
struct sdw_cdns_streams *stream,
|
||||||
u32 ch, u32 dir)
|
u32 ch, u32 dir, int dai_id)
|
||||||
{
|
{
|
||||||
struct sdw_cdns_pdi *pdi = NULL;
|
struct sdw_cdns_pdi *pdi = NULL;
|
||||||
|
|
||||||
if (dir == SDW_DATA_DIR_RX)
|
if (dir == SDW_DATA_DIR_RX)
|
||||||
pdi = cdns_find_pdi(cdns, 0, stream->num_in, stream->in);
|
pdi = cdns_find_pdi(cdns, 0, stream->num_in, stream->in,
|
||||||
|
dai_id);
|
||||||
else
|
else
|
||||||
pdi = cdns_find_pdi(cdns, 0, stream->num_out, stream->out);
|
pdi = cdns_find_pdi(cdns, 0, stream->num_out, stream->out,
|
||||||
|
dai_id);
|
||||||
|
|
||||||
/* check if we found a PDI, else find in bi-directional */
|
/* check if we found a PDI, else find in bi-directional */
|
||||||
if (!pdi)
|
if (!pdi)
|
||||||
pdi = cdns_find_pdi(cdns, 2, stream->num_bd, stream->bd);
|
pdi = cdns_find_pdi(cdns, 2, stream->num_bd, stream->bd,
|
||||||
|
dai_id);
|
||||||
|
|
||||||
if (pdi) {
|
if (pdi) {
|
||||||
pdi->l_ch_num = 0;
|
pdi->l_ch_num = 0;
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
/**
|
/**
|
||||||
* struct sdw_cdns_pdi: PDI (Physical Data Interface) instance
|
* struct sdw_cdns_pdi: PDI (Physical Data Interface) instance
|
||||||
*
|
*
|
||||||
* @assigned: pdi assigned
|
|
||||||
* @num: pdi number
|
* @num: pdi number
|
||||||
* @intel_alh_id: link identifier
|
* @intel_alh_id: link identifier
|
||||||
* @l_ch_num: low channel for PDI
|
* @l_ch_num: low channel for PDI
|
||||||
|
@ -18,7 +17,6 @@
|
||||||
* @type: stream type, PDM or PCM
|
* @type: stream type, PDM or PCM
|
||||||
*/
|
*/
|
||||||
struct sdw_cdns_pdi {
|
struct sdw_cdns_pdi {
|
||||||
bool assigned;
|
|
||||||
int num;
|
int num;
|
||||||
int intel_alh_id;
|
int intel_alh_id;
|
||||||
int l_ch_num;
|
int l_ch_num;
|
||||||
|
@ -154,7 +152,7 @@ int sdw_cdns_get_stream(struct sdw_cdns *cdns,
|
||||||
u32 ch, u32 dir);
|
u32 ch, u32 dir);
|
||||||
struct sdw_cdns_pdi *sdw_cdns_alloc_pdi(struct sdw_cdns *cdns,
|
struct sdw_cdns_pdi *sdw_cdns_alloc_pdi(struct sdw_cdns *cdns,
|
||||||
struct sdw_cdns_streams *stream,
|
struct sdw_cdns_streams *stream,
|
||||||
u32 ch, u32 dir);
|
u32 ch, u32 dir, int dai_id);
|
||||||
void sdw_cdns_config_stream(struct sdw_cdns *cdns,
|
void sdw_cdns_config_stream(struct sdw_cdns *cdns,
|
||||||
u32 ch, u32 dir, struct sdw_cdns_pdi *pdi);
|
u32 ch, u32 dir, struct sdw_cdns_pdi *pdi);
|
||||||
|
|
||||||
|
|
|
@ -631,11 +631,10 @@ static int intel_hw_params(struct snd_pcm_substream *substream,
|
||||||
if (dma->stream_type == SDW_STREAM_PDM)
|
if (dma->stream_type == SDW_STREAM_PDM)
|
||||||
pcm = false;
|
pcm = false;
|
||||||
|
|
||||||
/* FIXME: We would need to get PDI info from topology */
|
|
||||||
if (pcm)
|
if (pcm)
|
||||||
pdi = sdw_cdns_alloc_pdi(cdns, &cdns->pcm, ch, dir);
|
pdi = sdw_cdns_alloc_pdi(cdns, &cdns->pcm, ch, dir, dai->id);
|
||||||
else
|
else
|
||||||
pdi = sdw_cdns_alloc_pdi(cdns, &cdns->pdm, ch, dir);
|
pdi = sdw_cdns_alloc_pdi(cdns, &cdns->pdm, ch, dir, dai->id);
|
||||||
|
|
||||||
if (!pdi) {
|
if (!pdi) {
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
|
|
Loading…
Add table
Reference in a new issue