Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For soundwire 20190819 #5

Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions drivers/soundwire/algo_dynamic_allocation.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static void sdw_compute_slave_ports(struct sdw_master_runtime *m_rt,
ch = sdw_ch_mask_to_ch(p_rt->ch_mask);

sdw_fill_xport_params(&p_rt->transport_params,
p_rt->num, true,
p_rt->num, false,
SDW_BLK_GRP_CNT_1,
sample_int, port_bo, port_bo >> 8,
t_data->hstart,
Expand Down Expand Up @@ -96,7 +96,7 @@ static void sdw_compute_master_ports(struct sdw_master_runtime *m_rt,
no_ch = sdw_ch_mask_to_ch(p_rt->ch_mask);

sdw_fill_xport_params(&p_rt->transport_params, p_rt->num,
true, SDW_BLK_GRP_CNT_1, sample_int,
false, SDW_BLK_GRP_CNT_1, sample_int,
port_bo, port_bo >> 8, hstart, hstop,
(SDW_BLK_GRP_CNT_1 * no_ch), 0x0);

Expand Down
29 changes: 24 additions & 5 deletions drivers/soundwire/cadence_master.c
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,8 @@ static int cdns_allocate_pdi(struct sdw_cdns *cdns,
for (i = 0; i < num; i++) {
pdi[i].num = i + pdi_offset;
pdi[i].assigned = false;
pdi[i].link_id = -1;
pdi[i].dai_id = -1;
}

*stream = pdi;
Expand Down Expand Up @@ -1276,10 +1278,21 @@ EXPORT_SYMBOL(cdns_set_sdw_stream);
static struct sdw_cdns_pdi *cdns_find_pdi(struct sdw_cdns *cdns,
unsigned int offset,
unsigned int num,
struct sdw_cdns_pdi *pdi)
struct sdw_cdns_pdi *pdi,
int link_id,
int dai_id)
{
int i;

/* Check if we can find assigned pdi first */
for (i = offset; i < num; i++) {
if (pdi[i].link_id == link_id && pdi[i].dai_id == dai_id) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bardliao I don't think we need to use the link_id. The PDIs are already relative to the DAI being used. I will take this patch and remove the link_id

pdi[i].assigned = true;
return &pdi[i];
}
}

/* Assign a new one, if we can't find a assigned one */
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually this whole code is now irrelevant, we just need to use pdi[dai->id]
We could keep the check for assigned values, but that would be more for error checks that an actual allocation.

for (i = offset; i < num; i++) {
if (pdi[i].assigned)
continue;
Expand Down Expand Up @@ -1325,24 +1338,30 @@ EXPORT_SYMBOL(sdw_cdns_config_stream);
*/
struct sdw_cdns_pdi *sdw_cdns_alloc_pdi(struct sdw_cdns *cdns,
struct sdw_cdns_streams *stream,
u32 ch, u32 dir)
u32 ch, u32 dir, int dai_id)
{
struct sdw_cdns_pdi *pdi = NULL;

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,
cdns->bus.link_id, dai_id);
else
pdi = cdns_find_pdi(cdns, 0, stream->num_out, stream->out);
pdi = cdns_find_pdi(cdns, 0, stream->num_out, stream->out,
cdns->bus.link_id, dai_id);

/* check if we found a PDI, else find in bi-directional */
if (!pdi)
pdi = cdns_find_pdi(cdns, 2, stream->num_bd, stream->bd);
pdi = cdns_find_pdi(cdns, 2, stream->num_bd, stream->bd,
cdns->bus.link_id, dai_id);

if (pdi) {
pdi->l_ch_num = 0;
pdi->h_ch_num = ch - 1;
pdi->dir = dir;
pdi->ch_count = ch;
/* assign link_id and dai_id and we will reuse the pdi */
pdi->link_id = cdns->bus.link_id;
pdi->dai_id = dai_id;
}

return pdi;
Expand Down
4 changes: 3 additions & 1 deletion drivers/soundwire/cadence_master.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ struct sdw_cdns_pdi {
int l_ch_num;
int h_ch_num;
int ch_count;
int link_id;
int dai_id;
enum sdw_data_direction dir;
enum sdw_stream_type type;
};
Expand Down Expand Up @@ -155,7 +157,7 @@ int sdw_cdns_get_stream(struct sdw_cdns *cdns,
u32 ch, u32 dir);
struct sdw_cdns_pdi *sdw_cdns_alloc_pdi(struct sdw_cdns *cdns,
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,
u32 ch, u32 dir, struct sdw_cdns_pdi *pdi);

Expand Down
5 changes: 2 additions & 3 deletions drivers/soundwire/intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -767,11 +767,10 @@ static int intel_hw_params(struct snd_pcm_substream *substream,
if (dma->stream_type == SDW_STREAM_PDM)
pcm = false;

/* FIXME: We would need to get PDI info from topology */
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
pdi = sdw_cdns_alloc_pdi(cdns, &cdns->pdm, ch, dir);
pdi = sdw_cdns_alloc_pdi(cdns, &cdns->pdm, ch, dir, dai->id);

if (!pdi) {
ret = -EINVAL;
Expand Down