Skip to content

Commit 168cdf9

Browse files
bardliaovinodkoul
authored andcommitted
SoundWire: pass stream to compute_params()
The stream parameter will be used in the follow up commit. No function change. Signed-off-by: Bard Liao <[email protected]> Reviewed-by: Ranjani Sridharan <[email protected]> Reviewed-by: Péter Ujfalusi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 366fd59 commit 168cdf9

File tree

5 files changed

+85
-82
lines changed

5 files changed

+85
-82
lines changed

drivers/soundwire/amd_manager.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ static u32 amd_sdw_read_ping_status(struct sdw_bus *bus)
384384
return slave_stat;
385385
}
386386

387-
static int amd_sdw_compute_params(struct sdw_bus *bus)
387+
static int amd_sdw_compute_params(struct sdw_bus *bus, struct sdw_stream_runtime *stream)
388388
{
389389
struct sdw_transport_data t_data = {0};
390390
struct sdw_master_runtime *m_rt;

drivers/soundwire/generic_bandwidth_allocation.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ static void _sdw_compute_port_params(struct sdw_bus *bus,
170170
}
171171

172172
static int sdw_compute_group_params(struct sdw_bus *bus,
173+
struct sdw_stream_runtime *stream,
173174
struct sdw_group_params *params,
174175
struct sdw_group *group)
175176
{
@@ -319,8 +320,9 @@ static int sdw_get_group_count(struct sdw_bus *bus,
319320
* sdw_compute_port_params: Compute transport and port parameters
320321
*
321322
* @bus: SDW Bus instance
323+
* @stream: Soundwire stream
322324
*/
323-
static int sdw_compute_port_params(struct sdw_bus *bus)
325+
static int sdw_compute_port_params(struct sdw_bus *bus, struct sdw_stream_runtime *stream)
324326
{
325327
struct sdw_group_params *params = NULL;
326328
struct sdw_group group;
@@ -340,7 +342,7 @@ static int sdw_compute_port_params(struct sdw_bus *bus)
340342
}
341343

342344
/* Compute transport parameters for grouped streams */
343-
ret = sdw_compute_group_params(bus, params, &group);
345+
ret = sdw_compute_group_params(bus, stream, params, &group);
344346
if (ret < 0)
345347
goto free_params;
346348

@@ -592,8 +594,9 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
592594
* sdw_compute_params: Compute bus, transport and port parameters
593595
*
594596
* @bus: SDW Bus instance
597+
* @stream: Soundwire stream
595598
*/
596-
int sdw_compute_params(struct sdw_bus *bus)
599+
int sdw_compute_params(struct sdw_bus *bus, struct sdw_stream_runtime *stream)
597600
{
598601
int ret;
599602

@@ -603,7 +606,7 @@ int sdw_compute_params(struct sdw_bus *bus)
603606
return ret;
604607

605608
/* Compute transport and port params */
606-
ret = sdw_compute_port_params(bus);
609+
ret = sdw_compute_port_params(bus, stream);
607610
if (ret < 0) {
608611
dev_err(bus->dev, "Compute transport params failed: %d\n", ret);
609612
return ret;

drivers/soundwire/qcom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ static const struct sdw_master_ops qcom_swrm_ops = {
10721072
.pre_bank_switch = qcom_swrm_pre_bank_switch,
10731073
};
10741074

1075-
static int qcom_swrm_compute_params(struct sdw_bus *bus)
1075+
static int qcom_swrm_compute_params(struct sdw_bus *bus, struct sdw_stream_runtime *stream)
10761076
{
10771077
struct qcom_swrm_ctrl *ctrl = to_qcom_sdw(bus);
10781078
struct sdw_master_runtime *m_rt;

drivers/soundwire/stream.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,7 +1419,7 @@ static int _sdw_prepare_stream(struct sdw_stream_runtime *stream,
14191419

14201420
/* Compute params */
14211421
if (bus->compute_params) {
1422-
ret = bus->compute_params(bus);
1422+
ret = bus->compute_params(bus, stream);
14231423
if (ret < 0) {
14241424
dev_err(bus->dev, "Compute params failed: %d\n",
14251425
ret);
@@ -1721,7 +1721,7 @@ static int _sdw_deprepare_stream(struct sdw_stream_runtime *stream)
17211721

17221722
/* Compute params */
17231723
if (bus->compute_params) {
1724-
ret = bus->compute_params(bus);
1724+
ret = bus->compute_params(bus, stream);
17251725
if (ret < 0) {
17261726
dev_err(bus->dev, "Compute params failed: %d\n",
17271727
ret);

include/linux/soundwire/sdw.h

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -855,79 +855,6 @@ struct sdw_master_ops {
855855
int dev_num);
856856
};
857857

858-
/**
859-
* struct sdw_bus - SoundWire bus
860-
* @dev: Shortcut to &bus->md->dev to avoid changing the entire code.
861-
* @md: Master device
862-
* @bus_lock_key: bus lock key associated to @bus_lock
863-
* @bus_lock: bus lock
864-
* @slaves: list of Slaves on this bus
865-
* @msg_lock_key: message lock key associated to @msg_lock
866-
* @msg_lock: message lock
867-
* @m_rt_list: List of Master instance of all stream(s) running on Bus. This
868-
* is used to compute and program bus bandwidth, clock, frame shape,
869-
* transport and port parameters
870-
* @defer_msg: Defer message
871-
* @params: Current bus parameters
872-
* @stream_refcount: number of streams currently using this bus
873-
* @ops: Master callback ops
874-
* @port_ops: Master port callback ops
875-
* @prop: Master properties
876-
* @vendor_specific_prop: pointer to non-standard properties
877-
* @hw_sync_min_links: Number of links used by a stream above which
878-
* hardware-based synchronization is required. This value is only
879-
* meaningful if multi_link is set. If set to 1, hardware-based
880-
* synchronization will be used even if a stream only uses a single
881-
* SoundWire segment.
882-
* @controller_id: system-unique controller ID. If set to -1, the bus @id will be used.
883-
* @link_id: Link id number, can be 0 to N, unique for each Controller
884-
* @id: bus system-wide unique id
885-
* @compute_params: points to Bus resource management implementation
886-
* @assigned: Bitmap for Slave device numbers.
887-
* Bit set implies used number, bit clear implies unused number.
888-
* @clk_stop_timeout: Clock stop timeout computed
889-
* @bank_switch_timeout: Bank switch timeout computed
890-
* @domain: IRQ domain
891-
* @irq_chip: IRQ chip
892-
* @debugfs: Bus debugfs (optional)
893-
* @multi_link: Store bus property that indicates if multi links
894-
* are supported. This flag is populated by drivers after reading
895-
* appropriate firmware (ACPI/DT).
896-
* @lane_used_bandwidth: how much bandwidth in bits per second is used by each lane
897-
*/
898-
struct sdw_bus {
899-
struct device *dev;
900-
struct sdw_master_device *md;
901-
struct lock_class_key bus_lock_key;
902-
struct mutex bus_lock;
903-
struct list_head slaves;
904-
struct lock_class_key msg_lock_key;
905-
struct mutex msg_lock;
906-
struct list_head m_rt_list;
907-
struct sdw_defer defer_msg;
908-
struct sdw_bus_params params;
909-
int stream_refcount;
910-
const struct sdw_master_ops *ops;
911-
const struct sdw_master_port_ops *port_ops;
912-
struct sdw_master_prop prop;
913-
void *vendor_specific_prop;
914-
int hw_sync_min_links;
915-
int controller_id;
916-
unsigned int link_id;
917-
int id;
918-
int (*compute_params)(struct sdw_bus *bus);
919-
DECLARE_BITMAP(assigned, SDW_MAX_DEVICES);
920-
unsigned int clk_stop_timeout;
921-
u32 bank_switch_timeout;
922-
struct irq_chip irq_chip;
923-
struct irq_domain *domain;
924-
#ifdef CONFIG_DEBUG_FS
925-
struct dentry *debugfs;
926-
#endif
927-
bool multi_link;
928-
unsigned int lane_used_bandwidth[SDW_MAX_LANES];
929-
};
930-
931858
int sdw_bus_master_add(struct sdw_bus *bus, struct device *parent,
932859
struct fwnode_handle *fwnode);
933860
void sdw_bus_master_delete(struct sdw_bus *bus);
@@ -1017,10 +944,83 @@ struct sdw_stream_runtime {
1017944
struct list_head master_list;
1018945
};
1019946

947+
/**
948+
* struct sdw_bus - SoundWire bus
949+
* @dev: Shortcut to &bus->md->dev to avoid changing the entire code.
950+
* @md: Master device
951+
* @bus_lock_key: bus lock key associated to @bus_lock
952+
* @bus_lock: bus lock
953+
* @slaves: list of Slaves on this bus
954+
* @msg_lock_key: message lock key associated to @msg_lock
955+
* @msg_lock: message lock
956+
* @m_rt_list: List of Master instance of all stream(s) running on Bus. This
957+
* is used to compute and program bus bandwidth, clock, frame shape,
958+
* transport and port parameters
959+
* @defer_msg: Defer message
960+
* @params: Current bus parameters
961+
* @stream_refcount: number of streams currently using this bus
962+
* @ops: Master callback ops
963+
* @port_ops: Master port callback ops
964+
* @prop: Master properties
965+
* @vendor_specific_prop: pointer to non-standard properties
966+
* @hw_sync_min_links: Number of links used by a stream above which
967+
* hardware-based synchronization is required. This value is only
968+
* meaningful if multi_link is set. If set to 1, hardware-based
969+
* synchronization will be used even if a stream only uses a single
970+
* SoundWire segment.
971+
* @controller_id: system-unique controller ID. If set to -1, the bus @id will be used.
972+
* @link_id: Link id number, can be 0 to N, unique for each Controller
973+
* @id: bus system-wide unique id
974+
* @compute_params: points to Bus resource management implementation
975+
* @assigned: Bitmap for Slave device numbers.
976+
* Bit set implies used number, bit clear implies unused number.
977+
* @clk_stop_timeout: Clock stop timeout computed
978+
* @bank_switch_timeout: Bank switch timeout computed
979+
* @domain: IRQ domain
980+
* @irq_chip: IRQ chip
981+
* @debugfs: Bus debugfs (optional)
982+
* @multi_link: Store bus property that indicates if multi links
983+
* are supported. This flag is populated by drivers after reading
984+
* appropriate firmware (ACPI/DT).
985+
* @lane_used_bandwidth: how much bandwidth in bits per second is used by each lane
986+
*/
987+
struct sdw_bus {
988+
struct device *dev;
989+
struct sdw_master_device *md;
990+
struct lock_class_key bus_lock_key;
991+
struct mutex bus_lock;
992+
struct list_head slaves;
993+
struct lock_class_key msg_lock_key;
994+
struct mutex msg_lock;
995+
struct list_head m_rt_list;
996+
struct sdw_defer defer_msg;
997+
struct sdw_bus_params params;
998+
int stream_refcount;
999+
const struct sdw_master_ops *ops;
1000+
const struct sdw_master_port_ops *port_ops;
1001+
struct sdw_master_prop prop;
1002+
void *vendor_specific_prop;
1003+
int hw_sync_min_links;
1004+
int controller_id;
1005+
unsigned int link_id;
1006+
int id;
1007+
int (*compute_params)(struct sdw_bus *bus, struct sdw_stream_runtime *stream);
1008+
DECLARE_BITMAP(assigned, SDW_MAX_DEVICES);
1009+
unsigned int clk_stop_timeout;
1010+
u32 bank_switch_timeout;
1011+
struct irq_chip irq_chip;
1012+
struct irq_domain *domain;
1013+
#ifdef CONFIG_DEBUG_FS
1014+
struct dentry *debugfs;
1015+
#endif
1016+
bool multi_link;
1017+
unsigned int lane_used_bandwidth[SDW_MAX_LANES];
1018+
};
1019+
10201020
struct sdw_stream_runtime *sdw_alloc_stream(const char *stream_name);
10211021
void sdw_release_stream(struct sdw_stream_runtime *stream);
10221022

1023-
int sdw_compute_params(struct sdw_bus *bus);
1023+
int sdw_compute_params(struct sdw_bus *bus, struct sdw_stream_runtime *stream);
10241024

10251025
int sdw_stream_add_master(struct sdw_bus *bus,
10261026
struct sdw_stream_config *stream_config,

0 commit comments

Comments
 (0)