Skip to content

Commit 903cbf5

Browse files
bardliaoujfalusi
authored andcommitted
soundwire: record Peripheral scale_index
Currently, we program bus clock scale index unconditionally. It is not necessary if the new index is the same as the current one. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
1 parent 2b8fa85 commit 903cbf5

3 files changed

Lines changed: 7 additions & 0 deletions

File tree

drivers/soundwire/bus.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,6 +1411,7 @@ static int sdw_slave_set_frequency(struct sdw_slave *slave)
14111411
dev_err(&slave->dev,
14121412
"SDW_SCP_BUSCLOCK_SCALE_B1 write failed:%d\n", ret);
14131413

1414+
slave->scale_index = scale_index;
14141415
return ret;
14151416
}
14161417

drivers/soundwire/stream.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,9 @@ static int sdw_program_params(struct sdw_bus *bus, bool prepare)
705705
if (scale_index < 0)
706706
return scale_index;
707707

708+
if (scale_index == slave->scale_index)
709+
continue;
710+
708711
/* Skip the unattached Peripherals */
709712
if (!completion_done(&slave->enumeration_complete)) {
710713
dev_warn(&slave->dev,
@@ -717,6 +720,7 @@ static int sdw_program_params(struct sdw_bus *bus, bool prepare)
717720
dev_err(&slave->dev, "SDW_SCP_BUSCLOCK_SCALE register write failed\n");
718721
return ret;
719722
}
723+
slave->scale_index = scale_index;
720724
}
721725

722726
manager_runtime:

include/linux/soundwire/sdw.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@ struct sdw_slave_ops {
661661
* protocol for SoundWire mockup devices
662662
* @sdw_dev_lock: mutex used to protect callbacks/remove races
663663
* @sdca_data: structure containing all device data for SDCA helpers
664+
* @scale_index: current bus clock scaling index
664665
*/
665666
struct sdw_slave {
666667
struct sdw_slave_id id;
@@ -686,6 +687,7 @@ struct sdw_slave {
686687
bool is_mockup_device;
687688
struct mutex sdw_dev_lock; /* protect callbacks/remove races */
688689
struct sdca_device_data sdca_data;
690+
unsigned int scale_index;
689691
};
690692

691693
#define dev_to_sdw_dev(_dev) container_of(_dev, struct sdw_slave, dev)

0 commit comments

Comments
 (0)