Skip to content

Commit cada244

Browse files
committed
soundwire: intel_ace2x: handle multi BPT sections
Calculate required PDI buffer and pass the section number to the cdns BPT helpers. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
1 parent 50fe309 commit cada244

1 file changed

Lines changed: 34 additions & 11 deletions

File tree

drivers/soundwire/intel_ace2x.c

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ static int intel_ace2x_bpt_open_stream(struct sdw_intel *sdw, struct sdw_slave *
5757
struct sdw_port_config *pconfig;
5858
unsigned int pdi0_buf_size_pre_frame;
5959
unsigned int pdi1_buf_size_pre_frame;
60+
unsigned int pdi0_buffer_size_;
61+
unsigned int pdi1_buffer_size_;
6062
unsigned int pdi0_buffer_size;
6163
unsigned int tx_dma_bandwidth;
6264
unsigned int pdi1_buffer_size;
@@ -68,6 +70,7 @@ static int intel_ace2x_bpt_open_stream(struct sdw_intel *sdw, struct sdw_slave *
6870
struct sdw_cdns_pdi *pdi1;
6971
unsigned int rx_alignment;
7072
unsigned int tx_alignment;
73+
unsigned int num_frames_;
7174
unsigned int num_frames;
7275
unsigned int fake_size;
7376
unsigned int tx_pad;
@@ -76,6 +79,7 @@ static int intel_ace2x_bpt_open_stream(struct sdw_intel *sdw, struct sdw_slave *
7679
int ret1;
7780
int ret;
7881
int dir;
82+
int len;
7983
int i;
8084

8185
stream = sdw_alloc_stream("BPT", SDW_STREAM_BPT);
@@ -155,11 +159,25 @@ static int intel_ace2x_bpt_open_stream(struct sdw_intel *sdw, struct sdw_slave *
155159
if (ret < 0)
156160
goto deprepare_stream;
157161

158-
ret = sdw_cdns_bpt_find_buffer_sizes(command, cdns->bus.params.row, cdns->bus.params.col,
159-
msg->sec[0].len, SDW_BPT_MSG_MAX_BYTES, &data_per_frame,
160-
&pdi0_buffer_size, &pdi1_buffer_size, &num_frames);
161-
if (ret < 0)
162-
goto deprepare_stream;
162+
len = 0;
163+
pdi0_buffer_size = 0;
164+
pdi1_buffer_size = 0;
165+
num_frames = 0;
166+
/* Add up pdi buffer size and frame numbers of each BPT sections */
167+
for (i = 0; i < msg->sections; i++) {
168+
ret = sdw_cdns_bpt_find_buffer_sizes(command, cdns->bus.params.row,
169+
cdns->bus.params.col,
170+
msg->sec[i].len, SDW_BPT_MSG_MAX_BYTES,
171+
&data_per_frame, &pdi0_buffer_size_,
172+
&pdi1_buffer_size_, &num_frames_);
173+
if (ret < 0)
174+
goto deprepare_stream;
175+
176+
len += msg->sec[i].len;
177+
pdi0_buffer_size += pdi0_buffer_size_;
178+
pdi1_buffer_size += pdi1_buffer_size_;
179+
num_frames += num_frames_;
180+
}
163181

164182
sdw->bpt_ctx.pdi0_buffer_size = pdi0_buffer_size;
165183
sdw->bpt_ctx.pdi1_buffer_size = pdi1_buffer_size;
@@ -205,7 +223,7 @@ static int intel_ace2x_bpt_open_stream(struct sdw_intel *sdw, struct sdw_slave *
205223
}
206224

207225
dev_dbg(cdns->dev, "Message len %d transferred in %d frames (%d per frame)\n",
208-
msg->sec[0].len, num_frames, data_per_frame);
226+
len, num_frames, data_per_frame);
209227
dev_dbg(cdns->dev, "sizes pdi0 %d pdi1 %d tx_bandwidth %d rx_bandwidth %d\n",
210228
pdi0_buffer_size, pdi1_buffer_size, tx_dma_bandwidth, rx_dma_bandwidth);
211229

@@ -220,12 +238,12 @@ static int intel_ace2x_bpt_open_stream(struct sdw_intel *sdw, struct sdw_slave *
220238
}
221239

222240
if (!command) {
223-
ret = sdw_cdns_prepare_write_dma_buffer(msg->dev_num, msg->sec, 1,
241+
ret = sdw_cdns_prepare_write_dma_buffer(msg->dev_num, msg->sec, msg->sections,
224242
data_per_frame,
225243
sdw->bpt_ctx.dmab_tx_bdl.area,
226244
pdi0_buffer_size, &tx_total_bytes);
227245
} else {
228-
ret = sdw_cdns_prepare_read_dma_buffer(msg->dev_num, msg->sec, 1,
246+
ret = sdw_cdns_prepare_read_dma_buffer(msg->dev_num, msg->sec, msg->sections,
229247
data_per_frame,
230248
sdw->bpt_ctx.dmab_tx_bdl.area,
231249
pdi0_buffer_size, &tx_total_bytes, fake_size);
@@ -303,11 +321,16 @@ static int intel_ace2x_bpt_send_async(struct sdw_intel *sdw, struct sdw_slave *s
303321
struct sdw_bpt_msg *msg)
304322
{
305323
struct sdw_cdns *cdns = &sdw->cdns;
324+
int len = 0;
306325
int ret;
326+
int i;
327+
328+
for (i = 0; i < msg->sections; i++)
329+
len += msg->sec[i].len;
307330

308-
if (msg->sec[0].len < INTEL_BPT_MSG_BYTE_MIN) {
331+
if (len < INTEL_BPT_MSG_BYTE_MIN) {
309332
dev_err(cdns->dev, "BPT message length %d is less than the minimum bytes %d\n",
310-
msg->sec[0].len, INTEL_BPT_MSG_BYTE_MIN);
333+
len, INTEL_BPT_MSG_BYTE_MIN);
311334
return -EINVAL;
312335
}
313336

@@ -367,7 +390,7 @@ static int intel_ace2x_bpt_wait(struct sdw_intel *sdw, struct sdw_slave *slave,
367390
} else {
368391
ret = sdw_cdns_check_read_response(cdns->dev, sdw->bpt_ctx.dmab_rx_bdl.area,
369392
sdw->bpt_ctx.pdi1_buffer_size,
370-
msg->sec, 1, sdw->bpt_ctx.num_frames,
393+
msg->sec, msg->sections, sdw->bpt_ctx.num_frames,
371394
sdw->bpt_ctx.data_per_frame);
372395
if (ret < 0)
373396
dev_err(cdns->dev, "%s: BPT Read failed %d\n", __func__, ret);

0 commit comments

Comments
 (0)