linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] ASoC: cs43130: Re-use generic struct u16_fract
@ 2022-05-02 12:04 Andy Shevchenko
  2022-05-04 15:48 ` Charles Keepax
  2022-05-05 15:12 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Andy Shevchenko @ 2022-05-02 12:04 UTC (permalink / raw)
  To: Andy Shevchenko, alsa-devel, patches, linux-kernel
  Cc: James Schulman, David Rhodes, Lucas Tanure, Richard Fitzgerald,
	Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai

Instead of custom data type re-use generic struct u16_fract.
No changes intended.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 sound/soc/codecs/cs43130.c |  16 ++--
 sound/soc/codecs/cs43130.h | 151 +++++++++++++++++++------------------
 2 files changed, 84 insertions(+), 83 deletions(-)

diff --git a/sound/soc/codecs/cs43130.c b/sound/soc/codecs/cs43130.c
index 04548b577ad5..a2bce0f9f247 100644
--- a/sound/soc/codecs/cs43130.c
+++ b/sound/soc/codecs/cs43130.c
@@ -712,30 +712,30 @@ static int cs43130_set_sp_fmt(int dai_id, unsigned int bitwidth_sclk,
 	case CS43130_ASP_PCM_DAI:
 	case CS43130_ASP_DOP_DAI:
 		regmap_write(cs43130->regmap, CS43130_ASP_DEN_1,
-			     (clk_gen->den & CS43130_SP_M_LSB_DATA_MASK) >>
+			     (clk_gen->v.denominator & CS43130_SP_M_LSB_DATA_MASK) >>
 			     CS43130_SP_M_LSB_DATA_SHIFT);
 		regmap_write(cs43130->regmap, CS43130_ASP_DEN_2,
-			     (clk_gen->den & CS43130_SP_M_MSB_DATA_MASK) >>
+			     (clk_gen->v.denominator & CS43130_SP_M_MSB_DATA_MASK) >>
 			     CS43130_SP_M_MSB_DATA_SHIFT);
 		regmap_write(cs43130->regmap, CS43130_ASP_NUM_1,
-			     (clk_gen->num & CS43130_SP_N_LSB_DATA_MASK) >>
+			     (clk_gen->v.numerator & CS43130_SP_N_LSB_DATA_MASK) >>
 			     CS43130_SP_N_LSB_DATA_SHIFT);
 		regmap_write(cs43130->regmap, CS43130_ASP_NUM_2,
-			     (clk_gen->num & CS43130_SP_N_MSB_DATA_MASK) >>
+			     (clk_gen->v.numerator & CS43130_SP_N_MSB_DATA_MASK) >>
 			     CS43130_SP_N_MSB_DATA_SHIFT);
 		break;
 	case CS43130_XSP_DOP_DAI:
 		regmap_write(cs43130->regmap, CS43130_XSP_DEN_1,
-			     (clk_gen->den & CS43130_SP_M_LSB_DATA_MASK) >>
+			     (clk_gen->v.denominator & CS43130_SP_M_LSB_DATA_MASK) >>
 			     CS43130_SP_M_LSB_DATA_SHIFT);
 		regmap_write(cs43130->regmap, CS43130_XSP_DEN_2,
-			     (clk_gen->den & CS43130_SP_M_MSB_DATA_MASK) >>
+			     (clk_gen->v.denominator & CS43130_SP_M_MSB_DATA_MASK) >>
 			     CS43130_SP_M_MSB_DATA_SHIFT);
 		regmap_write(cs43130->regmap, CS43130_XSP_NUM_1,
-			     (clk_gen->num & CS43130_SP_N_LSB_DATA_MASK) >>
+			     (clk_gen->v.numerator & CS43130_SP_N_LSB_DATA_MASK) >>
 			     CS43130_SP_N_LSB_DATA_SHIFT);
 		regmap_write(cs43130->regmap, CS43130_XSP_NUM_2,
-			     (clk_gen->num & CS43130_SP_N_MSB_DATA_MASK) >>
+			     (clk_gen->v.numerator & CS43130_SP_N_MSB_DATA_MASK) >>
 			     CS43130_SP_N_MSB_DATA_SHIFT);
 		break;
 	default:
diff --git a/sound/soc/codecs/cs43130.h b/sound/soc/codecs/cs43130.h
index e62d671e95bb..1dd893674313 100644
--- a/sound/soc/codecs/cs43130.h
+++ b/sound/soc/codecs/cs43130.h
@@ -10,6 +10,8 @@
 #ifndef __CS43130_H__
 #define __CS43130_H__
 
+#include <linux/math.h>
+
 /* CS43130 registers addresses */
 /* all reg address is shifted by a byte for control byte to be LSB */
 #define CS43130_FIRSTREG	0x010000
@@ -372,97 +374,96 @@ enum cs43130_dai_id {
 };
 
 struct cs43130_clk_gen {
-	unsigned int	mclk_int;
-	int		fs;
-	u16		den;
-	u16		num;
+	unsigned int		mclk_int;
+	int			fs;
+	struct u16_fract	v;
 };
 
 /* frm_size = 16 */
 static const struct cs43130_clk_gen cs43130_16_clk_gen[] = {
-	{22579200,	32000,		441,		10,},
-	{22579200,	44100,		32,		1,},
-	{22579200,	48000,		147,		5,},
-	{22579200,	88200,		16,		1,},
-	{22579200,	96000,		147,		10,},
-	{22579200,	176400,		8,		1,},
-	{22579200,	192000,		147,		20,},
-	{22579200,	352800,		4,		1,},
-	{22579200,	384000,		147,		40,},
-	{24576000,	32000,		48,		1,},
-	{24576000,	44100,		5120,		147,},
-	{24576000,	48000,		32,		1,},
-	{24576000,	88200,		2560,		147,},
-	{24576000,	96000,		16,		1,},
-	{24576000,	176400,		1280,		147,},
-	{24576000,	192000,		8,		1,},
-	{24576000,	352800,		640,		147,},
-	{24576000,	384000,		4,		1,},
+	{ 22579200,	32000,		.v = { 441,	10, }, },
+	{ 22579200,	44100,		.v = { 32,	1, }, },
+	{ 22579200,	48000,		.v = { 147,	5, }, },
+	{ 22579200,	88200,		.v = { 16,	1, }, },
+	{ 22579200,	96000,		.v = { 147,	10, }, },
+	{ 22579200,	176400,		.v = { 8,	1, }, },
+	{ 22579200,	192000,		.v = { 147,	20, }, },
+	{ 22579200,	352800,		.v = { 4,	1, }, },
+	{ 22579200,	384000,		.v = { 147,	40, }, },
+	{ 24576000,	32000,		.v = { 48,	1, }, },
+	{ 24576000,	44100,		.v = { 5120,	147, }, },
+	{ 24576000,	48000,		.v = { 32,	1, }, },
+	{ 24576000,	88200,		.v = { 2560,	147, }, },
+	{ 24576000,	96000,		.v = { 16,	1, }, },
+	{ 24576000,	176400,		.v = { 1280,	147, }, },
+	{ 24576000,	192000,		.v = { 8,	1, }, },
+	{ 24576000,	352800,		.v = { 640,	147, }, },
+	{ 24576000,	384000,		.v = { 4,	1, }, },
 };
 
 /* frm_size = 32 */
 static const struct cs43130_clk_gen cs43130_32_clk_gen[] = {
-	{22579200,	32000,		441,		20,},
-	{22579200,	44100,		16,		1,},
-	{22579200,	48000,		147,		10,},
-	{22579200,	88200,		8,		1,},
-	{22579200,	96000,		147,		20,},
-	{22579200,	176400,		4,		1,},
-	{22579200,	192000,		147,		40,},
-	{22579200,	352800,		2,		1,},
-	{22579200,	384000,		147,		80,},
-	{24576000,	32000,		24,		1,},
-	{24576000,	44100,		2560,		147,},
-	{24576000,	48000,		16,		1,},
-	{24576000,	88200,		1280,		147,},
-	{24576000,	96000,		8,		1,},
-	{24576000,	176400,		640,		147,},
-	{24576000,	192000,		4,		1,},
-	{24576000,	352800,		320,		147,},
-	{24576000,	384000,		2,		1,},
+	{ 22579200,	32000,		.v = { 441,	20, }, },
+	{ 22579200,	44100,		.v = { 16,	1, }, },
+	{ 22579200,	48000,		.v = { 147,	10, }, },
+	{ 22579200,	88200,		.v = { 8,	1, }, },
+	{ 22579200,	96000,		.v = { 147,	20, }, },
+	{ 22579200,	176400,		.v = { 4,	1, }, },
+	{ 22579200,	192000,		.v = { 147,	40, }, },
+	{ 22579200,	352800,		.v = { 2,	1, }, },
+	{ 22579200,	384000,		.v = { 147,	80, }, },
+	{ 24576000,	32000,		.v = { 24,	1, }, },
+	{ 24576000,	44100,		.v = { 2560,	147, }, },
+	{ 24576000,	48000,		.v = { 16,	1, }, },
+	{ 24576000,	88200,		.v = { 1280,	147, }, },
+	{ 24576000,	96000,		.v = { 8,	1, }, },
+	{ 24576000,	176400,		.v = { 640,	147, }, },
+	{ 24576000,	192000,		.v = { 4,	1, }, },
+	{ 24576000,	352800,		.v = { 320,	147, }, },
+	{ 24576000,	384000,		.v = { 2,	1, }, },
 };
 
 /* frm_size = 48 */
 static const struct cs43130_clk_gen cs43130_48_clk_gen[] = {
-	{22579200,	32000,		147,		100,},
-	{22579200,	44100,		32,		3,},
-	{22579200,	48000,		49,		5,},
-	{22579200,	88200,		16,		3,},
-	{22579200,	96000,		49,		10,},
-	{22579200,	176400,		8,		3,},
-	{22579200,	192000,		49,		20,},
-	{22579200,	352800,		4,		3,},
-	{22579200,	384000,		49,		40,},
-	{24576000,	32000,		16,		1,},
-	{24576000,	44100,		5120,		441,},
-	{24576000,	48000,		32,		3,},
-	{24576000,	88200,		2560,		441,},
-	{24576000,	96000,		16,		3,},
-	{24576000,	176400,		1280,		441,},
-	{24576000,	192000,		8,		3,},
-	{24576000,	352800,		640,		441,},
-	{24576000,	384000,		4,		3,},
+	{ 22579200,	32000,		.v = { 147,	100, }, },
+	{ 22579200,	44100,		.v = { 32,	3, }, },
+	{ 22579200,	48000,		.v = { 49,	5, }, },
+	{ 22579200,	88200,		.v = { 16,	3, }, },
+	{ 22579200,	96000,		.v = { 49,	10, }, },
+	{ 22579200,	176400,		.v = { 8,	3, }, },
+	{ 22579200,	192000,		.v = { 49,	20, }, },
+	{ 22579200,	352800,		.v = { 4,	3, }, },
+	{ 22579200,	384000,		.v = { 49,	40, }, },
+	{ 24576000,	32000,		.v = { 16,	1, }, },
+	{ 24576000,	44100,		.v = { 5120,	441, }, },
+	{ 24576000,	48000,		.v = { 32,	3, }, },
+	{ 24576000,	88200,		.v = { 2560,	441, }, },
+	{ 24576000,	96000,		.v = { 16,	3, }, },
+	{ 24576000,	176400,		.v = { 1280,	441, }, },
+	{ 24576000,	192000,		.v = { 8,	3, }, },
+	{ 24576000,	352800,		.v = { 640,	441, }, },
+	{ 24576000,	384000,		.v = { 4,	3, }, },
 };
 
 /* frm_size = 64 */
 static const struct cs43130_clk_gen cs43130_64_clk_gen[] = {
-	{22579200,	32000,		441,		40,},
-	{22579200,	44100,		8,		1,},
-	{22579200,	48000,		147,		20,},
-	{22579200,	88200,		4,		1,},
-	{22579200,	96000,		147,		40,},
-	{22579200,	176400,		2,		1,},
-	{22579200,	192000,		147,		80,},
-	{22579200,	352800,		1,		1,},
-	{24576000,	32000,		12,		1,},
-	{24576000,	44100,		1280,		147,},
-	{24576000,	48000,		8,		1,},
-	{24576000,	88200,		640,		147,},
-	{24576000,	96000,		4,		1,},
-	{24576000,	176400,		320,		147,},
-	{24576000,	192000,		2,		1,},
-	{24576000,	352800,		160,		147,},
-	{24576000,	384000,		1,		1,},
+	{ 22579200,	32000,		.v = { 441,	40, }, },
+	{ 22579200,	44100,		.v = { 8,	1, }, },
+	{ 22579200,	48000,		.v = { 147,	20, }, },
+	{ 22579200,	88200,		.v = { 4,	1, }, },
+	{ 22579200,	96000,		.v = { 147,	40, }, },
+	{ 22579200,	176400,		.v = { 2,	1, }, },
+	{ 22579200,	192000,		.v = { 147,	80, }, },
+	{ 22579200,	352800,		.v = { 1,	1, }, },
+	{ 24576000,	32000,		.v = { 12,	1, }, },
+	{ 24576000,	44100,		.v = { 1280,	147, }, },
+	{ 24576000,	48000,		.v = { 8,	1, }, },
+	{ 24576000,	88200,		.v = { 640,	147, }, },
+	{ 24576000,	96000,		.v = { 4,	1, }, },
+	{ 24576000,	176400,		.v = { 320,	147, }, },
+	{ 24576000,	192000,		.v = { 2,	1, }, },
+	{ 24576000,	352800,		.v = { 160,	147, }, },
+	{ 24576000,	384000,		.v = { 1,	1, }, },
 };
 
 struct cs43130_bitwidth_map {
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/1] ASoC: cs43130: Re-use generic struct u16_fract
  2022-05-02 12:04 [PATCH v1 1/1] ASoC: cs43130: Re-use generic struct u16_fract Andy Shevchenko
@ 2022-05-04 15:48 ` Charles Keepax
  2022-05-05 15:12 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Charles Keepax @ 2022-05-04 15:48 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: alsa-devel, patches, linux-kernel, James Schulman, David Rhodes,
	Lucas Tanure, Richard Fitzgerald, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai

On Mon, May 02, 2022 at 03:04:55PM +0300, Andy Shevchenko wrote:
> Instead of custom data type re-use generic struct u16_fract.
> No changes intended.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---

Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>

Thanks,
Charles

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/1] ASoC: cs43130: Re-use generic struct u16_fract
  2022-05-02 12:04 [PATCH v1 1/1] ASoC: cs43130: Re-use generic struct u16_fract Andy Shevchenko
  2022-05-04 15:48 ` Charles Keepax
@ 2022-05-05 15:12 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2022-05-05 15:12 UTC (permalink / raw)
  To: linux-kernel, patches, alsa-devel, andriy.shevchenko
  Cc: lgirdwood, tanureal, tiwai, james.schulman, rf, perex, david.rhodes

On Mon, 2 May 2022 15:04:55 +0300, Andy Shevchenko wrote:
> Instead of custom data type re-use generic struct u16_fract.
> No changes intended.
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: cs43130: Re-use generic struct u16_fract
      commit: e14bd35ef44606c7d55ccb3660cededd421a14a1

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-05 15:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-02 12:04 [PATCH v1 1/1] ASoC: cs43130: Re-use generic struct u16_fract Andy Shevchenko
2022-05-04 15:48 ` Charles Keepax
2022-05-05 15:12 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).