Skip to content

Commit 188d194

Browse files
bardliaovinodkoul
authored andcommitted
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> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Tested-by: Shuming Fan <shumingf@realtek.com> Link: https://patch.msgid.link/20251021094355.132943-4-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent fe8a9cf commit 188d194

1 file changed

Lines changed: 34 additions & 12 deletions

File tree

drivers/soundwire/intel_ace2x.c

Lines changed: 34 additions & 12 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,12 +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,
160-
&data_per_frame, &pdi0_buffer_size, &pdi1_buffer_size,
161-
&num_frames);
162-
if (ret < 0)
163-
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+
}
164181

165182
sdw->bpt_ctx.pdi0_buffer_size = pdi0_buffer_size;
166183
sdw->bpt_ctx.pdi1_buffer_size = pdi1_buffer_size;
@@ -205,7 +222,7 @@ static int intel_ace2x_bpt_open_stream(struct sdw_intel *sdw, struct sdw_slave *
205222
}
206223

207224
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);
225+
len, num_frames, data_per_frame);
209226
dev_dbg(cdns->dev, "sizes pdi0 %d pdi1 %d tx_bandwidth %d rx_bandwidth %d\n",
210227
pdi0_buffer_size, pdi1_buffer_size, tx_dma_bandwidth, rx_dma_bandwidth);
211228

@@ -220,12 +237,12 @@ static int intel_ace2x_bpt_open_stream(struct sdw_intel *sdw, struct sdw_slave *
220237
}
221238

222239
if (!command) {
223-
ret = sdw_cdns_prepare_write_dma_buffer(msg->dev_num, msg->sec, 1,
240+
ret = sdw_cdns_prepare_write_dma_buffer(msg->dev_num, msg->sec, msg->sections,
224241
data_per_frame,
225242
sdw->bpt_ctx.dmab_tx_bdl.area,
226243
pdi0_buffer_size, &tx_total_bytes);
227244
} else {
228-
ret = sdw_cdns_prepare_read_dma_buffer(msg->dev_num, msg->sec, 1,
245+
ret = sdw_cdns_prepare_read_dma_buffer(msg->dev_num, msg->sec, msg->sections,
229246
data_per_frame,
230247
sdw->bpt_ctx.dmab_tx_bdl.area,
231248
pdi0_buffer_size, &tx_total_bytes,
@@ -304,11 +321,16 @@ static int intel_ace2x_bpt_send_async(struct sdw_intel *sdw, struct sdw_slave *s
304321
struct sdw_bpt_msg *msg)
305322
{
306323
struct sdw_cdns *cdns = &sdw->cdns;
324+
int len = 0;
307325
int ret;
326+
int i;
327+
328+
for (i = 0; i < msg->sections; i++)
329+
len += msg->sec[i].len;
308330

309-
if (msg->sec[0].len < INTEL_BPT_MSG_BYTE_MIN) {
331+
if (len < INTEL_BPT_MSG_BYTE_MIN) {
310332
dev_err(cdns->dev, "BPT message length %d is less than the minimum bytes %d\n",
311-
msg->sec[0].len, INTEL_BPT_MSG_BYTE_MIN);
333+
len, INTEL_BPT_MSG_BYTE_MIN);
312334
return -EINVAL;
313335
}
314336

@@ -368,7 +390,7 @@ static int intel_ace2x_bpt_wait(struct sdw_intel *sdw, struct sdw_slave *slave,
368390
} else {
369391
ret = sdw_cdns_check_read_response(cdns->dev, sdw->bpt_ctx.dmab_rx_bdl.area,
370392
sdw->bpt_ctx.pdi1_buffer_size,
371-
msg->sec, 1, sdw->bpt_ctx.num_frames,
393+
msg->sec, msg->sections, sdw->bpt_ctx.num_frames,
372394
sdw->bpt_ctx.data_per_frame);
373395
if (ret < 0)
374396
dev_err(cdns->dev, "%s: BPT Read failed %d\n", __func__, ret);

0 commit comments

Comments
 (0)