1 // SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
2 // Copyright(c) 2015-18 Intel Corporation.
5 * stream.c - SoundWire Bus stream operations.
8 #include <linux/delay.h>
9 #include <linux/device.h>
10 #include <linux/init.h>
11 #include <linux/module.h>
12 #include <linux/mod_devicetable.h>
13 #include <linux/slab.h>
14 #include <linux/soundwire/sdw_registers.h>
15 #include <linux/soundwire/sdw.h>
19 * Array of supported rows and columns as per MIPI SoundWire Specification 1.1
21 * The rows are arranged as per the array index value programmed
22 * in register. The index 15 has dummy value 0 in order to fill hole.
24 int sdw_rows
[SDW_FRAME_ROWS
] = {48, 50, 60, 64, 75, 80, 125, 147,
25 96, 100, 120, 128, 150, 160, 250, 0,
26 192, 200, 240, 256, 72, 144, 90, 180};
28 int sdw_cols
[SDW_FRAME_COLS
] = {2, 4, 6, 8, 10, 12, 14, 16};
30 int sdw_find_col_index(int col
)
34 for (i
= 0; i
< SDW_FRAME_COLS
; i
++) {
35 if (sdw_cols
[i
] == col
)
39 pr_warn("Requested column not found, selecting lowest column no: 2\n");
42 EXPORT_SYMBOL(sdw_find_col_index
);
44 int sdw_find_row_index(int row
)
48 for (i
= 0; i
< SDW_FRAME_ROWS
; i
++) {
49 if (sdw_rows
[i
] == row
)
53 pr_warn("Requested row not found, selecting lowest row no: 48\n");
56 EXPORT_SYMBOL(sdw_find_row_index
);
58 static int _sdw_program_slave_port_params(struct sdw_bus
*bus
,
59 struct sdw_slave
*slave
,
60 struct sdw_transport_params
*t_params
,
61 enum sdw_dpn_type type
)
63 u32 addr1
, addr2
, addr3
, addr4
;
67 if (bus
->params
.next_bank
) {
68 addr1
= SDW_DPN_OFFSETCTRL2_B1(t_params
->port_num
);
69 addr2
= SDW_DPN_BLOCKCTRL3_B1(t_params
->port_num
);
70 addr3
= SDW_DPN_SAMPLECTRL2_B1(t_params
->port_num
);
71 addr4
= SDW_DPN_HCTRL_B1(t_params
->port_num
);
73 addr1
= SDW_DPN_OFFSETCTRL2_B0(t_params
->port_num
);
74 addr2
= SDW_DPN_BLOCKCTRL3_B0(t_params
->port_num
);
75 addr3
= SDW_DPN_SAMPLECTRL2_B0(t_params
->port_num
);
76 addr4
= SDW_DPN_HCTRL_B0(t_params
->port_num
);
79 /* Program DPN_OffsetCtrl2 registers */
80 ret
= sdw_write(slave
, addr1
, t_params
->offset2
);
82 dev_err(bus
->dev
, "DPN_OffsetCtrl2 register write failed\n");
86 /* Program DPN_BlockCtrl3 register */
87 ret
= sdw_write(slave
, addr2
, t_params
->blk_pkg_mode
);
89 dev_err(bus
->dev
, "DPN_BlockCtrl3 register write failed\n");
94 * Data ports are FULL, SIMPLE and REDUCED. This function handles
95 * FULL and REDUCED only and beyond this point only FULL is
96 * handled, so bail out if we are not FULL data port type
98 if (type
!= SDW_DPN_FULL
)
101 /* Program DPN_SampleCtrl2 register */
102 wbuf
= (t_params
->sample_interval
- 1);
103 wbuf
&= SDW_DPN_SAMPLECTRL_HIGH
;
104 wbuf
>>= SDW_REG_SHIFT(SDW_DPN_SAMPLECTRL_HIGH
);
106 ret
= sdw_write(slave
, addr3
, wbuf
);
108 dev_err(bus
->dev
, "DPN_SampleCtrl2 register write failed\n");
112 /* Program DPN_HCtrl register */
113 wbuf
= t_params
->hstart
;
114 wbuf
<<= SDW_REG_SHIFT(SDW_DPN_HCTRL_HSTART
);
115 wbuf
|= t_params
->hstop
;
117 ret
= sdw_write(slave
, addr4
, wbuf
);
119 dev_err(bus
->dev
, "DPN_HCtrl register write failed\n");
124 static int sdw_program_slave_port_params(struct sdw_bus
*bus
,
125 struct sdw_slave_runtime
*s_rt
,
126 struct sdw_port_runtime
*p_rt
)
128 struct sdw_transport_params
*t_params
= &p_rt
->transport_params
;
129 struct sdw_port_params
*p_params
= &p_rt
->port_params
;
130 struct sdw_slave_prop
*slave_prop
= &s_rt
->slave
->prop
;
131 u32 addr1
, addr2
, addr3
, addr4
, addr5
, addr6
;
132 struct sdw_dpn_prop
*dpn_prop
;
136 dpn_prop
= sdw_get_slave_dpn_prop(s_rt
->slave
,
142 addr1
= SDW_DPN_PORTCTRL(t_params
->port_num
);
143 addr2
= SDW_DPN_BLOCKCTRL1(t_params
->port_num
);
145 if (bus
->params
.next_bank
) {
146 addr3
= SDW_DPN_SAMPLECTRL1_B1(t_params
->port_num
);
147 addr4
= SDW_DPN_OFFSETCTRL1_B1(t_params
->port_num
);
148 addr5
= SDW_DPN_BLOCKCTRL2_B1(t_params
->port_num
);
149 addr6
= SDW_DPN_LANECTRL_B1(t_params
->port_num
);
152 addr3
= SDW_DPN_SAMPLECTRL1_B0(t_params
->port_num
);
153 addr4
= SDW_DPN_OFFSETCTRL1_B0(t_params
->port_num
);
154 addr5
= SDW_DPN_BLOCKCTRL2_B0(t_params
->port_num
);
155 addr6
= SDW_DPN_LANECTRL_B0(t_params
->port_num
);
158 /* Program DPN_PortCtrl register */
159 wbuf
= p_params
->data_mode
<< SDW_REG_SHIFT(SDW_DPN_PORTCTRL_DATAMODE
);
160 wbuf
|= p_params
->flow_mode
;
162 ret
= sdw_update(s_rt
->slave
, addr1
, 0xF, wbuf
);
164 dev_err(&s_rt
->slave
->dev
,
165 "DPN_PortCtrl register write failed for port %d\n",
170 /* Program DPN_BlockCtrl1 register */
171 ret
= sdw_write(s_rt
->slave
, addr2
, (p_params
->bps
- 1));
173 dev_err(&s_rt
->slave
->dev
,
174 "DPN_BlockCtrl1 register write failed for port %d\n",
179 /* Program DPN_SampleCtrl1 register */
180 wbuf
= (t_params
->sample_interval
- 1) & SDW_DPN_SAMPLECTRL_LOW
;
181 ret
= sdw_write(s_rt
->slave
, addr3
, wbuf
);
183 dev_err(&s_rt
->slave
->dev
,
184 "DPN_SampleCtrl1 register write failed for port %d\n",
189 /* Program DPN_OffsetCtrl1 registers */
190 ret
= sdw_write(s_rt
->slave
, addr4
, t_params
->offset1
);
192 dev_err(&s_rt
->slave
->dev
,
193 "DPN_OffsetCtrl1 register write failed for port %d\n",
198 /* Program DPN_BlockCtrl2 register*/
199 if (t_params
->blk_grp_ctrl_valid
) {
200 ret
= sdw_write(s_rt
->slave
, addr5
, t_params
->blk_grp_ctrl
);
202 dev_err(&s_rt
->slave
->dev
,
203 "DPN_BlockCtrl2 reg write failed for port %d\n",
209 /* program DPN_LaneCtrl register */
210 if (slave_prop
->lane_control_support
) {
211 ret
= sdw_write(s_rt
->slave
, addr6
, t_params
->lane_ctrl
);
213 dev_err(&s_rt
->slave
->dev
,
214 "DPN_LaneCtrl register write failed for port %d\n",
220 if (dpn_prop
->type
!= SDW_DPN_SIMPLE
) {
221 ret
= _sdw_program_slave_port_params(bus
, s_rt
->slave
,
222 t_params
, dpn_prop
->type
);
224 dev_err(&s_rt
->slave
->dev
,
225 "Transport reg write failed for port: %d\n",
232 static int sdw_program_master_port_params(struct sdw_bus
*bus
,
233 struct sdw_port_runtime
*p_rt
)
238 * we need to set transport and port parameters for the port.
239 * Transport parameters refers to the sample interval, offsets and
240 * hstart/stop etc of the data. Port parameters refers to word
241 * length, flow mode etc of the port
243 ret
= bus
->port_ops
->dpn_set_port_transport_params(bus
,
244 &p_rt
->transport_params
,
245 bus
->params
.next_bank
);
249 return bus
->port_ops
->dpn_set_port_params(bus
,
251 bus
->params
.next_bank
);
255 * sdw_program_port_params() - Programs transport parameters of Master(s)
258 * @m_rt: Master stream runtime
260 static int sdw_program_port_params(struct sdw_master_runtime
*m_rt
)
262 struct sdw_slave_runtime
*s_rt
= NULL
;
263 struct sdw_bus
*bus
= m_rt
->bus
;
264 struct sdw_port_runtime
*p_rt
;
267 /* Program transport & port parameters for Slave(s) */
268 list_for_each_entry(s_rt
, &m_rt
->slave_rt_list
, m_rt_node
) {
269 list_for_each_entry(p_rt
, &s_rt
->port_list
, port_node
) {
270 ret
= sdw_program_slave_port_params(bus
, s_rt
, p_rt
);
276 /* Program transport & port parameters for Master(s) */
277 list_for_each_entry(p_rt
, &m_rt
->port_list
, port_node
) {
278 ret
= sdw_program_master_port_params(bus
, p_rt
);
287 * sdw_enable_disable_slave_ports: Enable/disable slave data port
290 * @s_rt: slave runtime
291 * @p_rt: port runtime
292 * @en: enable or disable operation
294 * This function only sets the enable/disable bits in the relevant bank, the
295 * actual enable/disable is done with a bank switch
297 static int sdw_enable_disable_slave_ports(struct sdw_bus
*bus
,
298 struct sdw_slave_runtime
*s_rt
,
299 struct sdw_port_runtime
*p_rt
,
302 struct sdw_transport_params
*t_params
= &p_rt
->transport_params
;
306 if (bus
->params
.next_bank
)
307 addr
= SDW_DPN_CHANNELEN_B1(p_rt
->num
);
309 addr
= SDW_DPN_CHANNELEN_B0(p_rt
->num
);
312 * Since bus doesn't support sharing a port across two streams,
313 * it is safe to reset this register
316 ret
= sdw_update(s_rt
->slave
, addr
, 0xFF, p_rt
->ch_mask
);
318 ret
= sdw_update(s_rt
->slave
, addr
, 0xFF, 0x0);
321 dev_err(&s_rt
->slave
->dev
,
322 "Slave chn_en reg write failed:%d port:%d\n",
323 ret
, t_params
->port_num
);
328 static int sdw_enable_disable_master_ports(struct sdw_master_runtime
*m_rt
,
329 struct sdw_port_runtime
*p_rt
,
332 struct sdw_transport_params
*t_params
= &p_rt
->transport_params
;
333 struct sdw_bus
*bus
= m_rt
->bus
;
334 struct sdw_enable_ch enable_ch
;
337 enable_ch
.port_num
= p_rt
->num
;
338 enable_ch
.ch_mask
= p_rt
->ch_mask
;
339 enable_ch
.enable
= en
;
341 /* Perform Master port channel(s) enable/disable */
342 if (bus
->port_ops
->dpn_port_enable_ch
) {
343 ret
= bus
->port_ops
->dpn_port_enable_ch(bus
,
345 bus
->params
.next_bank
);
348 "Master chn_en write failed:%d port:%d\n",
349 ret
, t_params
->port_num
);
354 "dpn_port_enable_ch not supported, %s failed\n",
355 en
? "enable" : "disable");
363 * sdw_enable_disable_ports() - Enable/disable port(s) for Master and
366 * @m_rt: Master stream runtime
367 * @en: mode (enable/disable)
369 static int sdw_enable_disable_ports(struct sdw_master_runtime
*m_rt
, bool en
)
371 struct sdw_port_runtime
*s_port
, *m_port
;
372 struct sdw_slave_runtime
*s_rt
;
375 /* Enable/Disable Slave port(s) */
376 list_for_each_entry(s_rt
, &m_rt
->slave_rt_list
, m_rt_node
) {
377 list_for_each_entry(s_port
, &s_rt
->port_list
, port_node
) {
378 ret
= sdw_enable_disable_slave_ports(m_rt
->bus
, s_rt
,
385 /* Enable/Disable Master port(s) */
386 list_for_each_entry(m_port
, &m_rt
->port_list
, port_node
) {
387 ret
= sdw_enable_disable_master_ports(m_rt
, m_port
, en
);
395 static int sdw_do_port_prep(struct sdw_slave_runtime
*s_rt
,
396 struct sdw_prepare_ch prep_ch
,
397 enum sdw_port_prep_ops cmd
)
399 const struct sdw_slave_ops
*ops
= s_rt
->slave
->ops
;
402 if (ops
->port_prep
) {
403 ret
= ops
->port_prep(s_rt
->slave
, &prep_ch
, cmd
);
405 dev_err(&s_rt
->slave
->dev
,
406 "Slave Port Prep cmd %d failed: %d\n",
415 static int sdw_prep_deprep_slave_ports(struct sdw_bus
*bus
,
416 struct sdw_slave_runtime
*s_rt
,
417 struct sdw_port_runtime
*p_rt
,
420 struct completion
*port_ready
;
421 struct sdw_dpn_prop
*dpn_prop
;
422 struct sdw_prepare_ch prep_ch
;
423 unsigned int time_left
;
428 prep_ch
.num
= p_rt
->num
;
429 prep_ch
.ch_mask
= p_rt
->ch_mask
;
431 dpn_prop
= sdw_get_slave_dpn_prop(s_rt
->slave
,
436 "Slave Port:%d properties not found\n", prep_ch
.num
);
440 prep_ch
.prepare
= prep
;
442 prep_ch
.bank
= bus
->params
.next_bank
;
444 if (dpn_prop
->imp_def_interrupts
|| !dpn_prop
->simple_ch_prep_sm
)
448 * Enable interrupt before Port prepare.
449 * For Port de-prepare, it is assumed that port
450 * was prepared earlier
453 ret
= sdw_configure_dpn_intr(s_rt
->slave
, p_rt
->num
, prep
,
454 dpn_prop
->imp_def_interrupts
);
459 /* Inform slave about the impending port prepare */
460 sdw_do_port_prep(s_rt
, prep_ch
, SDW_OPS_PORT_PRE_PREP
);
462 /* Prepare Slave port implementing CP_SM */
463 if (!dpn_prop
->simple_ch_prep_sm
) {
464 addr
= SDW_DPN_PREPARECTRL(p_rt
->num
);
467 ret
= sdw_update(s_rt
->slave
, addr
,
468 0xFF, p_rt
->ch_mask
);
470 ret
= sdw_update(s_rt
->slave
, addr
, 0xFF, 0x0);
473 dev_err(&s_rt
->slave
->dev
,
474 "Slave prep_ctrl reg write failed\n");
478 /* Wait for completion on port ready */
479 port_ready
= &s_rt
->slave
->port_ready
[prep_ch
.num
];
480 time_left
= wait_for_completion_timeout(port_ready
,
481 msecs_to_jiffies(dpn_prop
->ch_prep_timeout
));
483 val
= sdw_read(s_rt
->slave
, SDW_DPN_PREPARESTATUS(p_rt
->num
));
484 val
&= p_rt
->ch_mask
;
485 if (!time_left
|| val
) {
486 dev_err(&s_rt
->slave
->dev
,
487 "Chn prep failed for port:%d\n", prep_ch
.num
);
492 /* Inform slaves about ports prepared */
493 sdw_do_port_prep(s_rt
, prep_ch
, SDW_OPS_PORT_POST_PREP
);
495 /* Disable interrupt after Port de-prepare */
497 ret
= sdw_configure_dpn_intr(s_rt
->slave
, p_rt
->num
, prep
,
498 dpn_prop
->imp_def_interrupts
);
503 static int sdw_prep_deprep_master_ports(struct sdw_master_runtime
*m_rt
,
504 struct sdw_port_runtime
*p_rt
,
507 struct sdw_transport_params
*t_params
= &p_rt
->transport_params
;
508 struct sdw_bus
*bus
= m_rt
->bus
;
509 const struct sdw_master_port_ops
*ops
= bus
->port_ops
;
510 struct sdw_prepare_ch prep_ch
;
513 prep_ch
.num
= p_rt
->num
;
514 prep_ch
.ch_mask
= p_rt
->ch_mask
;
515 prep_ch
.prepare
= prep
; /* Prepare/De-prepare */
516 prep_ch
.bank
= bus
->params
.next_bank
;
518 /* Pre-prepare/Pre-deprepare port(s) */
519 if (ops
->dpn_port_prep
) {
520 ret
= ops
->dpn_port_prep(bus
, &prep_ch
);
522 dev_err(bus
->dev
, "Port prepare failed for port:%d\n",
532 * sdw_prep_deprep_ports() - Prepare/De-prepare port(s) for Master(s) and
535 * @m_rt: Master runtime handle
536 * @prep: Prepare or De-prepare
538 static int sdw_prep_deprep_ports(struct sdw_master_runtime
*m_rt
, bool prep
)
540 struct sdw_slave_runtime
*s_rt
;
541 struct sdw_port_runtime
*p_rt
;
544 /* Prepare/De-prepare Slave port(s) */
545 list_for_each_entry(s_rt
, &m_rt
->slave_rt_list
, m_rt_node
) {
546 list_for_each_entry(p_rt
, &s_rt
->port_list
, port_node
) {
547 ret
= sdw_prep_deprep_slave_ports(m_rt
->bus
, s_rt
,
554 /* Prepare/De-prepare Master port(s) */
555 list_for_each_entry(p_rt
, &m_rt
->port_list
, port_node
) {
556 ret
= sdw_prep_deprep_master_ports(m_rt
, p_rt
, prep
);
565 * sdw_notify_config() - Notify bus configuration
567 * @m_rt: Master runtime handle
569 * This function notifies the Master(s) and Slave(s) of the
570 * new bus configuration.
572 static int sdw_notify_config(struct sdw_master_runtime
*m_rt
)
574 struct sdw_slave_runtime
*s_rt
;
575 struct sdw_bus
*bus
= m_rt
->bus
;
576 struct sdw_slave
*slave
;
579 if (bus
->ops
->set_bus_conf
) {
580 ret
= bus
->ops
->set_bus_conf(bus
, &bus
->params
);
585 list_for_each_entry(s_rt
, &m_rt
->slave_rt_list
, m_rt_node
) {
588 if (slave
->ops
->bus_config
) {
589 ret
= slave
->ops
->bus_config(slave
, &bus
->params
);
591 dev_err(bus
->dev
, "Notify Slave: %d failed\n",
601 * sdw_program_params() - Program transport and port parameters for Master(s)
604 * @bus: SDW bus instance
606 static int sdw_program_params(struct sdw_bus
*bus
)
608 struct sdw_master_runtime
*m_rt
;
611 list_for_each_entry(m_rt
, &bus
->m_rt_list
, bus_node
) {
612 ret
= sdw_program_port_params(m_rt
);
615 "Program transport params failed: %d\n", ret
);
619 ret
= sdw_notify_config(m_rt
);
622 "Notify bus config failed: %d\n", ret
);
626 /* Enable port(s) on alternate bank for all active streams */
627 if (m_rt
->stream
->state
!= SDW_STREAM_ENABLED
)
630 ret
= sdw_enable_disable_ports(m_rt
, true);
632 dev_err(bus
->dev
, "Enable channel failed: %d\n", ret
);
640 static int sdw_bank_switch(struct sdw_bus
*bus
, int m_rt_count
)
642 int col_index
, row_index
;
644 struct sdw_msg
*wr_msg
;
649 wr_msg
= kzalloc(sizeof(*wr_msg
), GFP_KERNEL
);
653 bus
->defer_msg
.msg
= wr_msg
;
655 wbuf
= kzalloc(sizeof(*wbuf
), GFP_KERNEL
);
661 /* Get row and column index to program register */
662 col_index
= sdw_find_col_index(bus
->params
.col
);
663 row_index
= sdw_find_row_index(bus
->params
.row
);
664 wbuf
[0] = col_index
| (row_index
<< 3);
666 if (bus
->params
.next_bank
)
667 addr
= SDW_SCP_FRAMECTRL_B1
;
669 addr
= SDW_SCP_FRAMECTRL_B0
;
671 sdw_fill_msg(wr_msg
, NULL
, addr
, 1, SDW_BROADCAST_DEV_NUM
,
672 SDW_MSG_FLAG_WRITE
, wbuf
);
673 wr_msg
->ssp_sync
= true;
676 * Set the multi_link flag only when both the hardware supports
677 * and there is a stream handled by multiple masters
679 multi_link
= bus
->multi_link
&& (m_rt_count
> 1);
682 ret
= sdw_transfer_defer(bus
, wr_msg
, &bus
->defer_msg
);
684 ret
= sdw_transfer(bus
, wr_msg
);
687 dev_err(bus
->dev
, "Slave frame_ctrl reg write failed\n");
694 bus
->defer_msg
.msg
= NULL
;
695 bus
->params
.curr_bank
= !bus
->params
.curr_bank
;
696 bus
->params
.next_bank
= !bus
->params
.next_bank
;
709 * sdw_ml_sync_bank_switch: Multilink register bank switch
711 * @bus: SDW bus instance
713 * Caller function should free the buffers on error
715 static int sdw_ml_sync_bank_switch(struct sdw_bus
*bus
)
717 unsigned long time_left
;
719 if (!bus
->multi_link
)
722 /* Wait for completion of transfer */
723 time_left
= wait_for_completion_timeout(&bus
->defer_msg
.complete
,
724 bus
->bank_switch_timeout
);
727 dev_err(bus
->dev
, "Controller Timed out on bank switch\n");
731 bus
->params
.curr_bank
= !bus
->params
.curr_bank
;
732 bus
->params
.next_bank
= !bus
->params
.next_bank
;
734 if (bus
->defer_msg
.msg
) {
735 kfree(bus
->defer_msg
.msg
->buf
);
736 kfree(bus
->defer_msg
.msg
);
742 static int do_bank_switch(struct sdw_stream_runtime
*stream
)
744 struct sdw_master_runtime
*m_rt
;
745 const struct sdw_master_ops
*ops
;
747 bool multi_link
= false;
750 list_for_each_entry(m_rt
, &stream
->master_list
, stream_node
) {
754 if (bus
->multi_link
) {
756 mutex_lock(&bus
->msg_lock
);
759 /* Pre-bank switch */
760 if (ops
->pre_bank_switch
) {
761 ret
= ops
->pre_bank_switch(bus
);
764 "Pre bank switch op failed: %d\n", ret
);
770 * Perform Bank switch operation.
771 * For multi link cases, the actual bank switch is
772 * synchronized across all Masters and happens later as a
773 * part of post_bank_switch ops.
775 ret
= sdw_bank_switch(bus
, stream
->m_rt_count
);
777 dev_err(bus
->dev
, "Bank switch failed: %d\n", ret
);
783 * For multi link cases, it is expected that the bank switch is
784 * triggered by the post_bank_switch for the first Master in the list
785 * and for the other Masters the post_bank_switch() should return doing
788 list_for_each_entry(m_rt
, &stream
->master_list
, stream_node
) {
792 /* Post-bank switch */
793 if (ops
->post_bank_switch
) {
794 ret
= ops
->post_bank_switch(bus
);
797 "Post bank switch op failed: %d\n",
801 } else if (bus
->multi_link
&& stream
->m_rt_count
> 1) {
803 "Post bank switch ops not implemented\n");
807 /* Set the bank switch timeout to default, if not set */
808 if (!bus
->bank_switch_timeout
)
809 bus
->bank_switch_timeout
= DEFAULT_BANK_SWITCH_TIMEOUT
;
811 /* Check if bank switch was successful */
812 ret
= sdw_ml_sync_bank_switch(bus
);
815 "multi link bank switch failed: %d\n", ret
);
820 mutex_unlock(&bus
->msg_lock
);
826 list_for_each_entry(m_rt
, &stream
->master_list
, stream_node
) {
829 kfree(bus
->defer_msg
.msg
->buf
);
830 kfree(bus
->defer_msg
.msg
);
836 list_for_each_entry(m_rt
, &stream
->master_list
, stream_node
) {
838 if (mutex_is_locked(&bus
->msg_lock
))
839 mutex_unlock(&bus
->msg_lock
);
847 * sdw_release_stream() - Free the assigned stream runtime
849 * @stream: SoundWire stream runtime
851 * sdw_release_stream should be called only once per stream
853 void sdw_release_stream(struct sdw_stream_runtime
*stream
)
857 EXPORT_SYMBOL(sdw_release_stream
);
860 * sdw_alloc_stream() - Allocate and return stream runtime
862 * @stream_name: SoundWire stream name
864 * Allocates a SoundWire stream runtime instance.
865 * sdw_alloc_stream should be called only once per stream. Typically
866 * invoked from ALSA/ASoC machine/platform driver.
868 struct sdw_stream_runtime
*sdw_alloc_stream(const char *stream_name
)
870 struct sdw_stream_runtime
*stream
;
872 stream
= kzalloc(sizeof(*stream
), GFP_KERNEL
);
876 stream
->name
= stream_name
;
877 INIT_LIST_HEAD(&stream
->master_list
);
878 stream
->state
= SDW_STREAM_ALLOCATED
;
879 stream
->m_rt_count
= 0;
883 EXPORT_SYMBOL(sdw_alloc_stream
);
885 static struct sdw_master_runtime
886 *sdw_find_master_rt(struct sdw_bus
*bus
,
887 struct sdw_stream_runtime
*stream
)
889 struct sdw_master_runtime
*m_rt
;
891 /* Retrieve Bus handle if already available */
892 list_for_each_entry(m_rt
, &stream
->master_list
, stream_node
) {
893 if (m_rt
->bus
== bus
)
901 * sdw_alloc_master_rt() - Allocates and initialize Master runtime handle
903 * @bus: SDW bus instance
904 * @stream_config: Stream configuration
905 * @stream: Stream runtime handle.
907 * This function is to be called with bus_lock held.
909 static struct sdw_master_runtime
910 *sdw_alloc_master_rt(struct sdw_bus
*bus
,
911 struct sdw_stream_config
*stream_config
,
912 struct sdw_stream_runtime
*stream
)
914 struct sdw_master_runtime
*m_rt
;
917 * check if Master is already allocated (as a result of Slave adding
918 * it first), if so skip allocation and go to configure
920 m_rt
= sdw_find_master_rt(bus
, stream
);
924 m_rt
= kzalloc(sizeof(*m_rt
), GFP_KERNEL
);
928 /* Initialization of Master runtime handle */
929 INIT_LIST_HEAD(&m_rt
->port_list
);
930 INIT_LIST_HEAD(&m_rt
->slave_rt_list
);
931 list_add_tail(&m_rt
->stream_node
, &stream
->master_list
);
933 list_add_tail(&m_rt
->bus_node
, &bus
->m_rt_list
);
936 m_rt
->ch_count
= stream_config
->ch_count
;
938 m_rt
->stream
= stream
;
939 m_rt
->direction
= stream_config
->direction
;
945 * sdw_alloc_slave_rt() - Allocate and initialize Slave runtime handle.
947 * @slave: Slave handle
948 * @stream_config: Stream configuration
949 * @stream: Stream runtime handle
951 * This function is to be called with bus_lock held.
953 static struct sdw_slave_runtime
954 *sdw_alloc_slave_rt(struct sdw_slave
*slave
,
955 struct sdw_stream_config
*stream_config
,
956 struct sdw_stream_runtime
*stream
)
958 struct sdw_slave_runtime
*s_rt
;
960 s_rt
= kzalloc(sizeof(*s_rt
), GFP_KERNEL
);
964 INIT_LIST_HEAD(&s_rt
->port_list
);
965 s_rt
->ch_count
= stream_config
->ch_count
;
966 s_rt
->direction
= stream_config
->direction
;
972 static void sdw_master_port_release(struct sdw_bus
*bus
,
973 struct sdw_master_runtime
*m_rt
)
975 struct sdw_port_runtime
*p_rt
, *_p_rt
;
977 list_for_each_entry_safe(p_rt
, _p_rt
, &m_rt
->port_list
, port_node
) {
978 list_del(&p_rt
->port_node
);
983 static void sdw_slave_port_release(struct sdw_bus
*bus
,
984 struct sdw_slave
*slave
,
985 struct sdw_stream_runtime
*stream
)
987 struct sdw_port_runtime
*p_rt
, *_p_rt
;
988 struct sdw_master_runtime
*m_rt
;
989 struct sdw_slave_runtime
*s_rt
;
991 list_for_each_entry(m_rt
, &stream
->master_list
, stream_node
) {
992 list_for_each_entry(s_rt
, &m_rt
->slave_rt_list
, m_rt_node
) {
993 if (s_rt
->slave
!= slave
)
996 list_for_each_entry_safe(p_rt
, _p_rt
,
997 &s_rt
->port_list
, port_node
) {
998 list_del(&p_rt
->port_node
);
1006 * sdw_release_slave_stream() - Free Slave(s) runtime handle
1008 * @slave: Slave handle.
1009 * @stream: Stream runtime handle.
1011 * This function is to be called with bus_lock held.
1013 static void sdw_release_slave_stream(struct sdw_slave
*slave
,
1014 struct sdw_stream_runtime
*stream
)
1016 struct sdw_slave_runtime
*s_rt
, *_s_rt
;
1017 struct sdw_master_runtime
*m_rt
;
1019 list_for_each_entry(m_rt
, &stream
->master_list
, stream_node
) {
1020 /* Retrieve Slave runtime handle */
1021 list_for_each_entry_safe(s_rt
, _s_rt
,
1022 &m_rt
->slave_rt_list
, m_rt_node
) {
1023 if (s_rt
->slave
== slave
) {
1024 list_del(&s_rt
->m_rt_node
);
1033 * sdw_release_master_stream() - Free Master runtime handle
1035 * @m_rt: Master runtime node
1036 * @stream: Stream runtime handle.
1038 * This function is to be called with bus_lock held
1039 * It frees the Master runtime handle and associated Slave(s) runtime
1040 * handle. If this is called first then sdw_release_slave_stream() will have
1041 * no effect as Slave(s) runtime handle would already be freed up.
1043 static void sdw_release_master_stream(struct sdw_master_runtime
*m_rt
,
1044 struct sdw_stream_runtime
*stream
)
1046 struct sdw_slave_runtime
*s_rt
, *_s_rt
;
1048 list_for_each_entry_safe(s_rt
, _s_rt
, &m_rt
->slave_rt_list
, m_rt_node
) {
1049 sdw_slave_port_release(s_rt
->slave
->bus
, s_rt
->slave
, stream
);
1050 sdw_release_slave_stream(s_rt
->slave
, stream
);
1053 list_del(&m_rt
->stream_node
);
1054 list_del(&m_rt
->bus_node
);
1059 * sdw_stream_remove_master() - Remove master from sdw_stream
1061 * @bus: SDW Bus instance
1062 * @stream: SoundWire stream
1064 * This removes and frees port_rt and master_rt from a stream
1066 int sdw_stream_remove_master(struct sdw_bus
*bus
,
1067 struct sdw_stream_runtime
*stream
)
1069 struct sdw_master_runtime
*m_rt
, *_m_rt
;
1071 mutex_lock(&bus
->bus_lock
);
1073 list_for_each_entry_safe(m_rt
, _m_rt
,
1074 &stream
->master_list
, stream_node
) {
1075 if (m_rt
->bus
!= bus
)
1078 sdw_master_port_release(bus
, m_rt
);
1079 sdw_release_master_stream(m_rt
, stream
);
1080 stream
->m_rt_count
--;
1083 if (list_empty(&stream
->master_list
))
1084 stream
->state
= SDW_STREAM_RELEASED
;
1086 mutex_unlock(&bus
->bus_lock
);
1090 EXPORT_SYMBOL(sdw_stream_remove_master
);
1093 * sdw_stream_remove_slave() - Remove slave from sdw_stream
1095 * @slave: SDW Slave instance
1096 * @stream: SoundWire stream
1098 * This removes and frees port_rt and slave_rt from a stream
1100 int sdw_stream_remove_slave(struct sdw_slave
*slave
,
1101 struct sdw_stream_runtime
*stream
)
1103 mutex_lock(&slave
->bus
->bus_lock
);
1105 sdw_slave_port_release(slave
->bus
, slave
, stream
);
1106 sdw_release_slave_stream(slave
, stream
);
1108 mutex_unlock(&slave
->bus
->bus_lock
);
1112 EXPORT_SYMBOL(sdw_stream_remove_slave
);
1115 * sdw_config_stream() - Configure the allocated stream
1118 * @stream: SoundWire stream
1119 * @stream_config: Stream configuration for audio stream
1120 * @is_slave: is API called from Slave or Master
1122 * This function is to be called with bus_lock held.
1124 static int sdw_config_stream(struct device
*dev
,
1125 struct sdw_stream_runtime
*stream
,
1126 struct sdw_stream_config
*stream_config
,
1130 * Update the stream rate, channel and bps based on data
1131 * source. For more than one data source (multilink),
1132 * match the rate, bps, stream type and increment number of channels.
1134 * If rate/bps is zero, it means the values are not set, so skip
1135 * comparison and allow the value to be set and stored in stream
1137 if (stream
->params
.rate
&&
1138 stream
->params
.rate
!= stream_config
->frame_rate
) {
1139 dev_err(dev
, "rate not matching, stream:%s\n", stream
->name
);
1143 if (stream
->params
.bps
&&
1144 stream
->params
.bps
!= stream_config
->bps
) {
1145 dev_err(dev
, "bps not matching, stream:%s\n", stream
->name
);
1149 stream
->type
= stream_config
->type
;
1150 stream
->params
.rate
= stream_config
->frame_rate
;
1151 stream
->params
.bps
= stream_config
->bps
;
1153 /* TODO: Update this check during Device-device support */
1155 stream
->params
.ch_count
+= stream_config
->ch_count
;
1160 static int sdw_is_valid_port_range(struct device
*dev
,
1161 struct sdw_port_runtime
*p_rt
)
1163 if (!SDW_VALID_PORT_RANGE(p_rt
->num
)) {
1165 "SoundWire: Invalid port number :%d\n", p_rt
->num
);
1172 static struct sdw_port_runtime
1173 *sdw_port_alloc(struct device
*dev
,
1174 struct sdw_port_config
*port_config
,
1177 struct sdw_port_runtime
*p_rt
;
1179 p_rt
= kzalloc(sizeof(*p_rt
), GFP_KERNEL
);
1183 p_rt
->ch_mask
= port_config
[port_index
].ch_mask
;
1184 p_rt
->num
= port_config
[port_index
].num
;
1189 static int sdw_master_port_config(struct sdw_bus
*bus
,
1190 struct sdw_master_runtime
*m_rt
,
1191 struct sdw_port_config
*port_config
,
1192 unsigned int num_ports
)
1194 struct sdw_port_runtime
*p_rt
;
1197 /* Iterate for number of ports to perform initialization */
1198 for (i
= 0; i
< num_ports
; i
++) {
1199 p_rt
= sdw_port_alloc(bus
->dev
, port_config
, i
);
1204 * TODO: Check port capabilities for requested
1205 * configuration (audio mode support)
1208 list_add_tail(&p_rt
->port_node
, &m_rt
->port_list
);
1214 static int sdw_slave_port_config(struct sdw_slave
*slave
,
1215 struct sdw_slave_runtime
*s_rt
,
1216 struct sdw_port_config
*port_config
,
1217 unsigned int num_config
)
1219 struct sdw_port_runtime
*p_rt
;
1222 /* Iterate for number of ports to perform initialization */
1223 for (i
= 0; i
< num_config
; i
++) {
1224 p_rt
= sdw_port_alloc(&slave
->dev
, port_config
, i
);
1229 * TODO: Check valid port range as defined by DisCo/
1232 ret
= sdw_is_valid_port_range(&slave
->dev
, p_rt
);
1239 * TODO: Check port capabilities for requested
1240 * configuration (audio mode support)
1243 list_add_tail(&p_rt
->port_node
, &s_rt
->port_list
);
1250 * sdw_stream_add_master() - Allocate and add master runtime to a stream
1252 * @bus: SDW Bus instance
1253 * @stream_config: Stream configuration for audio stream
1254 * @port_config: Port configuration for audio stream
1255 * @num_ports: Number of ports
1256 * @stream: SoundWire stream
1258 int sdw_stream_add_master(struct sdw_bus
*bus
,
1259 struct sdw_stream_config
*stream_config
,
1260 struct sdw_port_config
*port_config
,
1261 unsigned int num_ports
,
1262 struct sdw_stream_runtime
*stream
)
1264 struct sdw_master_runtime
*m_rt
;
1267 mutex_lock(&bus
->bus_lock
);
1270 * For multi link streams, add the second master only if
1271 * the bus supports it.
1272 * Check if bus->multi_link is set
1274 if (!bus
->multi_link
&& stream
->m_rt_count
> 0) {
1276 "Multilink not supported, link %d\n", bus
->link_id
);
1281 m_rt
= sdw_alloc_master_rt(bus
, stream_config
, stream
);
1284 "Master runtime config failed for stream:%s\n",
1290 ret
= sdw_config_stream(bus
->dev
, stream
, stream_config
, false);
1294 ret
= sdw_master_port_config(bus
, m_rt
, port_config
, num_ports
);
1298 stream
->m_rt_count
++;
1303 sdw_release_master_stream(m_rt
, stream
);
1305 mutex_unlock(&bus
->bus_lock
);
1308 EXPORT_SYMBOL(sdw_stream_add_master
);
1311 * sdw_stream_add_slave() - Allocate and add master/slave runtime to a stream
1313 * @slave: SDW Slave instance
1314 * @stream_config: Stream configuration for audio stream
1315 * @stream: SoundWire stream
1316 * @port_config: Port configuration for audio stream
1317 * @num_ports: Number of ports
1319 * It is expected that Slave is added before adding Master
1323 int sdw_stream_add_slave(struct sdw_slave
*slave
,
1324 struct sdw_stream_config
*stream_config
,
1325 struct sdw_port_config
*port_config
,
1326 unsigned int num_ports
,
1327 struct sdw_stream_runtime
*stream
)
1329 struct sdw_slave_runtime
*s_rt
;
1330 struct sdw_master_runtime
*m_rt
;
1333 mutex_lock(&slave
->bus
->bus_lock
);
1336 * If this API is invoked by Slave first then m_rt is not valid.
1337 * So, allocate m_rt and add Slave to it.
1339 m_rt
= sdw_alloc_master_rt(slave
->bus
, stream_config
, stream
);
1341 dev_err(&slave
->dev
,
1342 "alloc master runtime failed for stream:%s\n",
1348 s_rt
= sdw_alloc_slave_rt(slave
, stream_config
, stream
);
1350 dev_err(&slave
->dev
,
1351 "Slave runtime config failed for stream:%s\n",
1357 ret
= sdw_config_stream(&slave
->dev
, stream
, stream_config
, true);
1361 list_add_tail(&s_rt
->m_rt_node
, &m_rt
->slave_rt_list
);
1363 ret
= sdw_slave_port_config(slave
, s_rt
, port_config
, num_ports
);
1368 * Change stream state to CONFIGURED on first Slave add.
1369 * Bus is not aware of number of Slave(s) in a stream at this
1370 * point so cannot depend on all Slave(s) to be added in order to
1371 * change stream state to CONFIGURED.
1373 stream
->state
= SDW_STREAM_CONFIGURED
;
1378 * we hit error so cleanup the stream, release all Slave(s) and
1381 sdw_release_master_stream(m_rt
, stream
);
1383 mutex_unlock(&slave
->bus
->bus_lock
);
1386 EXPORT_SYMBOL(sdw_stream_add_slave
);
1389 * sdw_get_slave_dpn_prop() - Get Slave port capabilities
1391 * @slave: Slave handle
1392 * @direction: Data direction.
1393 * @port_num: Port number
1395 struct sdw_dpn_prop
*sdw_get_slave_dpn_prop(struct sdw_slave
*slave
,
1396 enum sdw_data_direction direction
,
1397 unsigned int port_num
)
1399 struct sdw_dpn_prop
*dpn_prop
;
1403 if (direction
== SDW_DATA_DIR_TX
) {
1404 num_ports
= hweight32(slave
->prop
.source_ports
);
1405 dpn_prop
= slave
->prop
.src_dpn_prop
;
1407 num_ports
= hweight32(slave
->prop
.sink_ports
);
1408 dpn_prop
= slave
->prop
.sink_dpn_prop
;
1411 for (i
= 0; i
< num_ports
; i
++) {
1412 if (dpn_prop
[i
].num
== port_num
)
1413 return &dpn_prop
[i
];
1420 * sdw_acquire_bus_lock: Acquire bus lock for all Master runtime(s)
1422 * @stream: SoundWire stream
1424 * Acquire bus_lock for each of the master runtime(m_rt) part of this
1425 * stream to reconfigure the bus.
1426 * NOTE: This function is called from SoundWire stream ops and is
1427 * expected that a global lock is held before acquiring bus_lock.
1429 static void sdw_acquire_bus_lock(struct sdw_stream_runtime
*stream
)
1431 struct sdw_master_runtime
*m_rt
;
1432 struct sdw_bus
*bus
= NULL
;
1434 /* Iterate for all Master(s) in Master list */
1435 list_for_each_entry(m_rt
, &stream
->master_list
, stream_node
) {
1438 mutex_lock(&bus
->bus_lock
);
1443 * sdw_release_bus_lock: Release bus lock for all Master runtime(s)
1445 * @stream: SoundWire stream
1447 * Release the previously held bus_lock after reconfiguring the bus.
1448 * NOTE: This function is called from SoundWire stream ops and is
1449 * expected that a global lock is held before releasing bus_lock.
1451 static void sdw_release_bus_lock(struct sdw_stream_runtime
*stream
)
1453 struct sdw_master_runtime
*m_rt
= NULL
;
1454 struct sdw_bus
*bus
= NULL
;
1456 /* Iterate for all Master(s) in Master list */
1457 list_for_each_entry_reverse(m_rt
, &stream
->master_list
, stream_node
) {
1459 mutex_unlock(&bus
->bus_lock
);
1463 static int _sdw_prepare_stream(struct sdw_stream_runtime
*stream
)
1465 struct sdw_master_runtime
*m_rt
;
1466 struct sdw_bus
*bus
= NULL
;
1467 struct sdw_master_prop
*prop
;
1468 struct sdw_bus_params params
;
1471 /* Prepare Master(s) and Slave(s) port(s) associated with stream */
1472 list_for_each_entry(m_rt
, &stream
->master_list
, stream_node
) {
1475 memcpy(¶ms
, &bus
->params
, sizeof(params
));
1477 /* TODO: Support Asynchronous mode */
1478 if ((prop
->max_clk_freq
% stream
->params
.rate
) != 0) {
1479 dev_err(bus
->dev
, "Async mode not supported\n");
1483 /* Increment cumulative bus bandwidth */
1484 /* TODO: Update this during Device-Device support */
1485 bus
->params
.bandwidth
+= m_rt
->stream
->params
.rate
*
1486 m_rt
->ch_count
* m_rt
->stream
->params
.bps
;
1488 /* Compute params */
1489 if (bus
->compute_params
) {
1490 ret
= bus
->compute_params(bus
);
1492 dev_err(bus
->dev
, "Compute params failed: %d",
1498 /* Program params */
1499 ret
= sdw_program_params(bus
);
1501 dev_err(bus
->dev
, "Program params failed: %d\n", ret
);
1502 goto restore_params
;
1507 pr_err("Configuration error in %s\n", __func__
);
1511 ret
= do_bank_switch(stream
);
1513 dev_err(bus
->dev
, "Bank switch failed: %d\n", ret
);
1514 goto restore_params
;
1517 list_for_each_entry(m_rt
, &stream
->master_list
, stream_node
) {
1520 /* Prepare port(s) on the new clock configuration */
1521 ret
= sdw_prep_deprep_ports(m_rt
, true);
1523 dev_err(bus
->dev
, "Prepare port(s) failed ret = %d\n",
1529 stream
->state
= SDW_STREAM_PREPARED
;
1534 memcpy(&bus
->params
, ¶ms
, sizeof(params
));
1539 * sdw_prepare_stream() - Prepare SoundWire stream
1541 * @stream: Soundwire stream
1543 * Documentation/driver-api/soundwire/stream.rst explains this API in detail
1545 int sdw_prepare_stream(struct sdw_stream_runtime
*stream
)
1550 pr_err("SoundWire: Handle not found for stream\n");
1554 sdw_acquire_bus_lock(stream
);
1556 ret
= _sdw_prepare_stream(stream
);
1558 sdw_release_bus_lock(stream
);
1561 EXPORT_SYMBOL(sdw_prepare_stream
);
1563 static int _sdw_enable_stream(struct sdw_stream_runtime
*stream
)
1565 struct sdw_master_runtime
*m_rt
;
1566 struct sdw_bus
*bus
= NULL
;
1569 /* Enable Master(s) and Slave(s) port(s) associated with stream */
1570 list_for_each_entry(m_rt
, &stream
->master_list
, stream_node
) {
1573 /* Program params */
1574 ret
= sdw_program_params(bus
);
1576 dev_err(bus
->dev
, "Program params failed: %d\n", ret
);
1580 /* Enable port(s) */
1581 ret
= sdw_enable_disable_ports(m_rt
, true);
1584 "Enable port(s) failed ret: %d\n", ret
);
1590 pr_err("Configuration error in %s\n", __func__
);
1594 ret
= do_bank_switch(stream
);
1596 dev_err(bus
->dev
, "Bank switch failed: %d\n", ret
);
1600 stream
->state
= SDW_STREAM_ENABLED
;
1605 * sdw_enable_stream() - Enable SoundWire stream
1607 * @stream: Soundwire stream
1609 * Documentation/driver-api/soundwire/stream.rst explains this API in detail
1611 int sdw_enable_stream(struct sdw_stream_runtime
*stream
)
1616 pr_err("SoundWire: Handle not found for stream\n");
1620 sdw_acquire_bus_lock(stream
);
1622 ret
= _sdw_enable_stream(stream
);
1624 sdw_release_bus_lock(stream
);
1627 EXPORT_SYMBOL(sdw_enable_stream
);
1629 static int _sdw_disable_stream(struct sdw_stream_runtime
*stream
)
1631 struct sdw_master_runtime
*m_rt
;
1634 list_for_each_entry(m_rt
, &stream
->master_list
, stream_node
) {
1635 struct sdw_bus
*bus
= m_rt
->bus
;
1637 /* Disable port(s) */
1638 ret
= sdw_enable_disable_ports(m_rt
, false);
1640 dev_err(bus
->dev
, "Disable port(s) failed: %d\n", ret
);
1644 stream
->state
= SDW_STREAM_DISABLED
;
1646 list_for_each_entry(m_rt
, &stream
->master_list
, stream_node
) {
1647 struct sdw_bus
*bus
= m_rt
->bus
;
1649 /* Program params */
1650 ret
= sdw_program_params(bus
);
1652 dev_err(bus
->dev
, "Program params failed: %d\n", ret
);
1657 ret
= do_bank_switch(stream
);
1659 pr_err("Bank switch failed: %d\n", ret
);
1663 /* make sure alternate bank (previous current) is also disabled */
1664 list_for_each_entry(m_rt
, &stream
->master_list
, stream_node
) {
1665 struct sdw_bus
*bus
= m_rt
->bus
;
1667 /* Disable port(s) */
1668 ret
= sdw_enable_disable_ports(m_rt
, false);
1670 dev_err(bus
->dev
, "Disable port(s) failed: %d\n", ret
);
1679 * sdw_disable_stream() - Disable SoundWire stream
1681 * @stream: Soundwire stream
1683 * Documentation/driver-api/soundwire/stream.rst explains this API in detail
1685 int sdw_disable_stream(struct sdw_stream_runtime
*stream
)
1690 pr_err("SoundWire: Handle not found for stream\n");
1694 sdw_acquire_bus_lock(stream
);
1696 ret
= _sdw_disable_stream(stream
);
1698 sdw_release_bus_lock(stream
);
1701 EXPORT_SYMBOL(sdw_disable_stream
);
1703 static int _sdw_deprepare_stream(struct sdw_stream_runtime
*stream
)
1705 struct sdw_master_runtime
*m_rt
;
1706 struct sdw_bus
*bus
;
1709 list_for_each_entry(m_rt
, &stream
->master_list
, stream_node
) {
1711 /* De-prepare port(s) */
1712 ret
= sdw_prep_deprep_ports(m_rt
, false);
1715 "De-prepare port(s) failed: %d\n", ret
);
1719 /* TODO: Update this during Device-Device support */
1720 bus
->params
.bandwidth
-= m_rt
->stream
->params
.rate
*
1721 m_rt
->ch_count
* m_rt
->stream
->params
.bps
;
1723 /* Program params */
1724 ret
= sdw_program_params(bus
);
1726 dev_err(bus
->dev
, "Program params failed: %d\n", ret
);
1731 stream
->state
= SDW_STREAM_DEPREPARED
;
1732 return do_bank_switch(stream
);
1736 * sdw_deprepare_stream() - Deprepare SoundWire stream
1738 * @stream: Soundwire stream
1740 * Documentation/driver-api/soundwire/stream.rst explains this API in detail
1742 int sdw_deprepare_stream(struct sdw_stream_runtime
*stream
)
1747 pr_err("SoundWire: Handle not found for stream\n");
1751 sdw_acquire_bus_lock(stream
);
1752 ret
= _sdw_deprepare_stream(stream
);
1754 sdw_release_bus_lock(stream
);
1757 EXPORT_SYMBOL(sdw_deprepare_stream
);