soundwire: export helpers to find row and column values
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Tue, 6 Aug 2019 00:55:10 +0000 (19:55 -0500)
committerVinod Koul <vkoul@kernel.org>
Wed, 21 Aug 2019 09:06:01 +0000 (14:36 +0530)
Add a prefix for common tables and export 2 helpers to set the frame
shapes based on row/col values.

These changes simplify bandwidth allocation algorithms as well as the
Cadence parts which all need to convert from frame shape to indices
used by the standard. These helpers are used in the following patch.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20190806005522.22642-6-pierre-louis.bossart@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/soundwire/bus.h
drivers/soundwire/stream.c

index 3048ca153f222b2bdfef7a3383f06a19cc770601..4429c51c5f86b3c3bf856d2f1fb15a7d68266b11 100644 (file)
@@ -49,8 +49,11 @@ struct sdw_msg {
 
 #define SDW_DOUBLE_RATE_FACTOR         2
 
-extern int rows[SDW_FRAME_ROWS];
-extern int cols[SDW_FRAME_COLS];
+extern int sdw_rows[SDW_FRAME_ROWS];
+extern int sdw_cols[SDW_FRAME_COLS];
+
+int sdw_find_row_index(int row);
+int sdw_find_col_index(int col);
 
 /**
  * sdw_port_runtime: Runtime port parameters for Master or Slave
index a0476755a4598066512201da2cba4d76981e8b89..53f5e790fcd753ebaa03c54c85252179bacc0170 100644 (file)
  * The rows are arranged as per the array index value programmed
  * in register. The index 15 has dummy value 0 in order to fill hole.
  */
-int rows[SDW_FRAME_ROWS] = {48, 50, 60, 64, 75, 80, 125, 147,
+int sdw_rows[SDW_FRAME_ROWS] = {48, 50, 60, 64, 75, 80, 125, 147,
                        96, 100, 120, 128, 150, 160, 250, 0,
                        192, 200, 240, 256, 72, 144, 90, 180};
 
-int cols[SDW_FRAME_COLS] = {2, 4, 6, 8, 10, 12, 14, 16};
+int sdw_cols[SDW_FRAME_COLS] = {2, 4, 6, 8, 10, 12, 14, 16};
 
-static int sdw_find_col_index(int col)
+int sdw_find_col_index(int col)
 {
        int i;
 
        for (i = 0; i < SDW_FRAME_COLS; i++) {
-               if (cols[i] == col)
+               if (sdw_cols[i] == col)
                        return i;
        }
 
        pr_warn("Requested column not found, selecting lowest column no: 2\n");
        return 0;
 }
+EXPORT_SYMBOL(sdw_find_col_index);
 
-static int sdw_find_row_index(int row)
+int sdw_find_row_index(int row)
 {
        int i;
 
        for (i = 0; i < SDW_FRAME_ROWS; i++) {
-               if (rows[i] == row)
+               if (sdw_rows[i] == row)
                        return i;
        }
 
        pr_warn("Requested row not found, selecting lowest row no: 48\n");
        return 0;
 }
+EXPORT_SYMBOL(sdw_find_row_index);
 
 static int _sdw_program_slave_port_params(struct sdw_bus *bus,
                                          struct sdw_slave *slave,