Skip to content

Commit

Permalink
SoundWire: pass stream to compute_params()
Browse files Browse the repository at this point in the history
The stream parameter will be used in the follow up commit.
No function change.

Signed-off-by: Bard Liao <[email protected]>
  • Loading branch information
bardliao committed Nov 21, 2024
1 parent b0dc371 commit 1ecd18b
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 64 deletions.
2 changes: 1 addition & 1 deletion drivers/soundwire/amd_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ static u32 amd_sdw_read_ping_status(struct sdw_bus *bus)
return slave_stat;
}

static int amd_sdw_compute_params(struct sdw_bus *bus)
static int amd_sdw_compute_params(struct sdw_bus *bus, struct sdw_stream_runtime *stream)
{
struct sdw_transport_data t_data = {0};
struct sdw_master_runtime *m_rt;
Expand Down
11 changes: 7 additions & 4 deletions drivers/soundwire/generic_bandwidth_allocation.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ static void _sdw_compute_port_params(struct sdw_bus *bus,
}

static int sdw_compute_group_params(struct sdw_bus *bus,
struct sdw_stream_runtime *stream,
struct sdw_group_params *params,
struct sdw_group *group)
{
Expand Down Expand Up @@ -321,8 +322,9 @@ static int sdw_get_group_count(struct sdw_bus *bus,
* sdw_compute_port_params: Compute transport and port parameters
*
* @bus: SDW Bus instance
* @stream: Soundwire stream
*/
static int sdw_compute_port_params(struct sdw_bus *bus)
static int sdw_compute_port_params(struct sdw_bus *bus, struct sdw_stream_runtime *stream)
{
struct sdw_group_params *params = NULL;
struct sdw_group group;
Expand All @@ -342,7 +344,7 @@ static int sdw_compute_port_params(struct sdw_bus *bus)
}

/* Compute transport parameters for grouped streams */
ret = sdw_compute_group_params(bus, params, &group);
ret = sdw_compute_group_params(bus, stream, params, &group);
if (ret < 0)
goto free_params;

Expand Down Expand Up @@ -594,8 +596,9 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
* sdw_compute_params: Compute bus, transport and port parameters
*
* @bus: SDW Bus instance
* @stream: Soundwire stream
*/
int sdw_compute_params(struct sdw_bus *bus)
int sdw_compute_params(struct sdw_bus *bus, struct sdw_stream_runtime *stream)
{
int ret;

Expand All @@ -605,7 +608,7 @@ int sdw_compute_params(struct sdw_bus *bus)
return ret;

/* Compute transport and port params */
ret = sdw_compute_port_params(bus);
ret = sdw_compute_port_params(bus, stream);
if (ret < 0) {
dev_err(bus->dev, "Compute transport params failed: %d\n", ret);
return ret;
Expand Down
4 changes: 2 additions & 2 deletions drivers/soundwire/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,7 @@ static int _sdw_prepare_stream(struct sdw_stream_runtime *stream,

/* Compute params */
if (bus->compute_params) {
ret = bus->compute_params(bus);
ret = bus->compute_params(bus, stream);
if (ret < 0) {
dev_err(bus->dev, "Compute params failed: %d\n",
ret);
Expand Down Expand Up @@ -1727,7 +1727,7 @@ static int _sdw_deprepare_stream(struct sdw_stream_runtime *stream)

/* Compute params */
if (bus->compute_params) {
ret = bus->compute_params(bus);
ret = bus->compute_params(bus, stream);
if (ret < 0) {
dev_err(bus->dev, "Compute params failed: %d\n",
ret);
Expand Down
114 changes: 57 additions & 57 deletions include/linux/soundwire/sdw.h
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,61 @@ struct sdw_master_ops {
int dev_num);
};

/**
* sdw_stream_state: Stream states
*
* @SDW_STREAM_ALLOCATED: New stream allocated.
* @SDW_STREAM_CONFIGURED: Stream configured
* @SDW_STREAM_PREPARED: Stream prepared
* @SDW_STREAM_ENABLED: Stream enabled
* @SDW_STREAM_DISABLED: Stream disabled
* @SDW_STREAM_DEPREPARED: Stream de-prepared
* @SDW_STREAM_RELEASED: Stream released
*/
enum sdw_stream_state {
SDW_STREAM_ALLOCATED = 0,
SDW_STREAM_CONFIGURED = 1,
SDW_STREAM_PREPARED = 2,
SDW_STREAM_ENABLED = 3,
SDW_STREAM_DISABLED = 4,
SDW_STREAM_DEPREPARED = 5,
SDW_STREAM_RELEASED = 6,
};

/**
* sdw_stream_params: Stream parameters
*
* @rate: Sampling frequency, in Hz
* @ch_count: Number of channels
* @bps: bits per channel sample
*/
struct sdw_stream_params {
unsigned int rate;
unsigned int ch_count;
unsigned int bps;
};

/**
* sdw_stream_runtime: Runtime stream parameters
*
* @name: SoundWire stream name
* @params: Stream parameters
* @state: Current state of the stream
* @type: Stream type PCM or PDM
* @m_rt_count: Count of Master runtime(s) in this stream
* @master_list: List of Master runtime(s) in this stream.
* master_list can contain only one m_rt per Master instance
* for a stream
*/
struct sdw_stream_runtime {
const char *name;
struct sdw_stream_params params;
enum sdw_stream_state state;
enum sdw_stream_type type;
int m_rt_count;
struct list_head master_list;
};

/**
* struct sdw_bus - SoundWire bus
* @dev: Shortcut to &bus->md->dev to avoid changing the entire code.
Expand Down Expand Up @@ -914,7 +969,7 @@ struct sdw_bus {
int controller_id;
unsigned int link_id;
int id;
int (*compute_params)(struct sdw_bus *bus);
int (*compute_params)(struct sdw_bus *bus, struct sdw_stream_runtime *stream);
DECLARE_BITMAP(assigned, SDW_MAX_DEVICES);
unsigned int clk_stop_timeout;
u32 bank_switch_timeout;
Expand Down Expand Up @@ -961,65 +1016,10 @@ struct sdw_stream_config {
enum sdw_stream_type type;
};

/**
* sdw_stream_state: Stream states
*
* @SDW_STREAM_ALLOCATED: New stream allocated.
* @SDW_STREAM_CONFIGURED: Stream configured
* @SDW_STREAM_PREPARED: Stream prepared
* @SDW_STREAM_ENABLED: Stream enabled
* @SDW_STREAM_DISABLED: Stream disabled
* @SDW_STREAM_DEPREPARED: Stream de-prepared
* @SDW_STREAM_RELEASED: Stream released
*/
enum sdw_stream_state {
SDW_STREAM_ALLOCATED = 0,
SDW_STREAM_CONFIGURED = 1,
SDW_STREAM_PREPARED = 2,
SDW_STREAM_ENABLED = 3,
SDW_STREAM_DISABLED = 4,
SDW_STREAM_DEPREPARED = 5,
SDW_STREAM_RELEASED = 6,
};

/**
* sdw_stream_params: Stream parameters
*
* @rate: Sampling frequency, in Hz
* @ch_count: Number of channels
* @bps: bits per channel sample
*/
struct sdw_stream_params {
unsigned int rate;
unsigned int ch_count;
unsigned int bps;
};

/**
* sdw_stream_runtime: Runtime stream parameters
*
* @name: SoundWire stream name
* @params: Stream parameters
* @state: Current state of the stream
* @type: Stream type PCM or PDM
* @m_rt_count: Count of Master runtime(s) in this stream
* @master_list: List of Master runtime(s) in this stream.
* master_list can contain only one m_rt per Master instance
* for a stream
*/
struct sdw_stream_runtime {
const char *name;
struct sdw_stream_params params;
enum sdw_stream_state state;
enum sdw_stream_type type;
int m_rt_count;
struct list_head master_list;
};

struct sdw_stream_runtime *sdw_alloc_stream(const char *stream_name);
void sdw_release_stream(struct sdw_stream_runtime *stream);

int sdw_compute_params(struct sdw_bus *bus);
int sdw_compute_params(struct sdw_bus *bus, struct sdw_stream_runtime *stream);

int sdw_stream_add_master(struct sdw_bus *bus,
struct sdw_stream_config *stream_config,
Expand Down

0 comments on commit 1ecd18b

Please sign in to comment.