public inbox for linux-sound@vger.kernel.org
 help / color / mirror / Atom feed
From: Vinod Koul <vkoul@kernel.org>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: linux-sound@vger.kernel.org, alsa-devel@alsa-project.org,
	tiwai@suse.de, broonie@kernel.org, vinod.koul@intel.com,
	Bard liao <yung-chuan.liao@linux.intel.com>,
	Ranjani Sridharan <ranjani.sridharan@linux.intel.com>,
	Peter Ujfalusi <peter.ujfalusi@linux.intel.com>,
	Kai Vehmanen <kai.vehmanen@linux.intel.com>,
	srinivas.kandagatla@linaro.org,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	vijendar.mukunda@amd.com,
	Charles Keepax <ckeepax@opensource.cirrus.com>,
	Richard Fitzgerald <rf@opensource.cirrus.com>,
	Shuming Fan <shumingf@realtek.com>, Jack Yu <jack.yu@realtek.com>,
	Oder Chiou <oder_chiou@realtek.com>
Subject: Re: [RFC PATCH 09/16] soundwire: crc8: add constant table
Date: Mon, 18 Dec 2023 17:31:04 +0530	[thread overview]
Message-ID: <ZYA0gKf3bZgY4X_s@matsya> (raw)
In-Reply-To: <20231207222944.663893-10-pierre-louis.bossart@linux.intel.com>

On 07-12-23, 16:29, Pierre-Louis Bossart wrote:
> Add the lookup table required by crc8(). All configuration values were
> directly table from the MIPI SoundWire 1.x specification.
> 
> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> ---
>  drivers/soundwire/Makefile |   4 +-
>  drivers/soundwire/crc8.c   | 277 +++++++++++++++++++++++++++++++++++++
>  drivers/soundwire/crc8.h   |  11 ++
>  3 files changed, 291 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/soundwire/crc8.c
>  create mode 100644 drivers/soundwire/crc8.h
> 
> diff --git a/drivers/soundwire/Makefile b/drivers/soundwire/Makefile
> index 657f5888a77b..170128dd9318 100644
> --- a/drivers/soundwire/Makefile
> +++ b/drivers/soundwire/Makefile
> @@ -5,7 +5,9 @@
>  
>  #Bus Objs
>  soundwire-bus-y := bus_type.o bus.o master.o slave.o mipi_disco.o stream.o  \
> -			sysfs_slave.o sysfs_slave_dpn.o
> +			sysfs_slave.o sysfs_slave_dpn.o \
> +			crc8.o
> +
>  obj-$(CONFIG_SOUNDWIRE) += soundwire-bus.o
>  
>  soundwire-generic-allocation-objs := generic_bandwidth_allocation.o
> diff --git a/drivers/soundwire/crc8.c b/drivers/soundwire/crc8.c
> new file mode 100644
> index 000000000000..b6b984d7f39a
> --- /dev/null
> +++ b/drivers/soundwire/crc8.c
> @@ -0,0 +1,277 @@
> +// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
> +// Copyright(c) 2024 Intel Corporation.
> +
> +#include <linux/crc8.h>
> +#include <linux/module.h>
> +#include "crc8.h"
> +
> +/*
> + * the MIPI SoundWire CRC8 polynomial is X^8 + X^6 + X^3 + X^2 + 1, MSB first
> + * The value is (1)01001101 = 0x4D
> + *
> + * the table below was generated with
> + *
> + *	u8 crc8_lookup_table[CRC8_TABLE_SIZE];
> + *	crc8_populate_msb(crc8_lookup_table, SDW_CRC8_POLY);

Good that you found this API, so next question would be why should we
have this static table in kernel and not generate on probe if bpt is
supported..? Many subsystems use these APIs to generate the tables..


> + *
> + */
> +
> +const u8 sdw_crc8_lookup_msb[CRC8_TABLE_SIZE] = {
> +	0x00, /* 0 */
> +	0x4d, /* 1 */
> +	0x9a, /* 2 */
> +	0xd7, /* 3 */
> +	0x79, /* 4 */
> +	0x34, /* 5 */
> +	0xe3, /* 6 */
> +	0xae, /* 7 */
> +	0xf2, /* 8 */
> +	0xbf, /* 9 */
> +	0x68, /* 10 */
> +	0x25, /* 11 */
> +	0x8b, /* 12 */
> +	0xc6, /* 13 */
> +	0x11, /* 14 */
> +	0x5c, /* 15 */
> +	0xa9, /* 16 */
> +	0xe4, /* 17 */
> +	0x33, /* 18 */
> +	0x7e, /* 19 */
> +	0xd0, /* 20 */
> +	0x9d, /* 21 */
> +	0x4a, /* 22 */
> +	0x07, /* 23 */
> +	0x5b, /* 24 */
> +	0x16, /* 25 */
> +	0xc1, /* 26 */
> +	0x8c, /* 27 */
> +	0x22, /* 28 */
> +	0x6f, /* 29 */
> +	0xb8, /* 30 */
> +	0xf5, /* 31 */
> +	0x1f, /* 32 */
> +	0x52, /* 33 */
> +	0x85, /* 34 */
> +	0xc8, /* 35 */
> +	0x66, /* 36 */
> +	0x2b, /* 37 */
> +	0xfc, /* 38 */
> +	0xb1, /* 39 */
> +	0xed, /* 40 */
> +	0xa0, /* 41 */
> +	0x77, /* 42 */
> +	0x3a, /* 43 */
> +	0x94, /* 44 */
> +	0xd9, /* 45 */
> +	0x0e, /* 46 */
> +	0x43, /* 47 */
> +	0xb6, /* 48 */
> +	0xfb, /* 49 */
> +	0x2c, /* 50 */
> +	0x61, /* 51 */
> +	0xcf, /* 52 */
> +	0x82, /* 53 */
> +	0x55, /* 54 */
> +	0x18, /* 55 */
> +	0x44, /* 56 */
> +	0x09, /* 57 */
> +	0xde, /* 58 */
> +	0x93, /* 59 */
> +	0x3d, /* 60 */
> +	0x70, /* 61 */
> +	0xa7, /* 62 */
> +	0xea, /* 63 */
> +	0x3e, /* 64 */
> +	0x73, /* 65 */
> +	0xa4, /* 66 */
> +	0xe9, /* 67 */
> +	0x47, /* 68 */
> +	0x0a, /* 69 */
> +	0xdd, /* 70 */
> +	0x90, /* 71 */
> +	0xcc, /* 72 */
> +	0x81, /* 73 */
> +	0x56, /* 74 */
> +	0x1b, /* 75 */
> +	0xb5, /* 76 */
> +	0xf8, /* 77 */
> +	0x2f, /* 78 */
> +	0x62, /* 79 */
> +	0x97, /* 80 */
> +	0xda, /* 81 */
> +	0x0d, /* 82 */
> +	0x40, /* 83 */
> +	0xee, /* 84 */
> +	0xa3, /* 85 */
> +	0x74, /* 86 */
> +	0x39, /* 87 */
> +	0x65, /* 88 */
> +	0x28, /* 89 */
> +	0xff, /* 90 */
> +	0xb2, /* 91 */
> +	0x1c, /* 92 */
> +	0x51, /* 93 */
> +	0x86, /* 94 */
> +	0xcb, /* 95 */
> +	0x21, /* 96 */
> +	0x6c, /* 97 */
> +	0xbb, /* 98 */
> +	0xf6, /* 99 */
> +	0x58, /* 100 */
> +	0x15, /* 101 */
> +	0xc2, /* 102 */
> +	0x8f, /* 103 */
> +	0xd3, /* 104 */
> +	0x9e, /* 105 */
> +	0x49, /* 106 */
> +	0x04, /* 107 */
> +	0xaa, /* 108 */
> +	0xe7, /* 109 */
> +	0x30, /* 110 */
> +	0x7d, /* 111 */
> +	0x88, /* 112 */
> +	0xc5, /* 113 */
> +	0x12, /* 114 */
> +	0x5f, /* 115 */
> +	0xf1, /* 116 */
> +	0xbc, /* 117 */
> +	0x6b, /* 118 */
> +	0x26, /* 119 */
> +	0x7a, /* 120 */
> +	0x37, /* 121 */
> +	0xe0, /* 122 */
> +	0xad, /* 123 */
> +	0x03, /* 124 */
> +	0x4e, /* 125 */
> +	0x99, /* 126 */
> +	0xd4, /* 127 */
> +	0x7c, /* 128 */
> +	0x31, /* 129 */
> +	0xe6, /* 130 */
> +	0xab, /* 131 */
> +	0x05, /* 132 */
> +	0x48, /* 133 */
> +	0x9f, /* 134 */
> +	0xd2, /* 135 */
> +	0x8e, /* 136 */
> +	0xc3, /* 137 */
> +	0x14, /* 138 */
> +	0x59, /* 139 */
> +	0xf7, /* 140 */
> +	0xba, /* 141 */
> +	0x6d, /* 142 */
> +	0x20, /* 143 */
> +	0xd5, /* 144 */
> +	0x98, /* 145 */
> +	0x4f, /* 146 */
> +	0x02, /* 147 */
> +	0xac, /* 148 */
> +	0xe1, /* 149 */
> +	0x36, /* 150 */
> +	0x7b, /* 151 */
> +	0x27, /* 152 */
> +	0x6a, /* 153 */
> +	0xbd, /* 154 */
> +	0xf0, /* 155 */
> +	0x5e, /* 156 */
> +	0x13, /* 157 */
> +	0xc4, /* 158 */
> +	0x89, /* 159 */
> +	0x63, /* 160 */
> +	0x2e, /* 161 */
> +	0xf9, /* 162 */
> +	0xb4, /* 163 */
> +	0x1a, /* 164 */
> +	0x57, /* 165 */
> +	0x80, /* 166 */
> +	0xcd, /* 167 */
> +	0x91, /* 168 */
> +	0xdc, /* 169 */
> +	0x0b, /* 170 */
> +	0x46, /* 171 */
> +	0xe8, /* 172 */
> +	0xa5, /* 173 */
> +	0x72, /* 174 */
> +	0x3f, /* 175 */
> +	0xca, /* 176 */
> +	0x87, /* 177 */
> +	0x50, /* 178 */
> +	0x1d, /* 179 */
> +	0xb3, /* 180 */
> +	0xfe, /* 181 */
> +	0x29, /* 182 */
> +	0x64, /* 183 */
> +	0x38, /* 184 */
> +	0x75, /* 185 */
> +	0xa2, /* 186 */
> +	0xef, /* 187 */
> +	0x41, /* 188 */
> +	0x0c, /* 189 */
> +	0xdb, /* 190 */
> +	0x96, /* 191 */
> +	0x42, /* 192 */
> +	0x0f, /* 193 */
> +	0xd8, /* 194 */
> +	0x95, /* 195 */
> +	0x3b, /* 196 */
> +	0x76, /* 197 */
> +	0xa1, /* 198 */
> +	0xec, /* 199 */
> +	0xb0, /* 200 */
> +	0xfd, /* 201 */
> +	0x2a, /* 202 */
> +	0x67, /* 203 */
> +	0xc9, /* 204 */
> +	0x84, /* 205 */
> +	0x53, /* 206 */
> +	0x1e, /* 207 */
> +	0xeb, /* 208 */
> +	0xa6, /* 209 */
> +	0x71, /* 210 */
> +	0x3c, /* 211 */
> +	0x92, /* 212 */
> +	0xdf, /* 213 */
> +	0x08, /* 214 */
> +	0x45, /* 215 */
> +	0x19, /* 216 */
> +	0x54, /* 217 */
> +	0x83, /* 218 */
> +	0xce, /* 219 */
> +	0x60, /* 220 */
> +	0x2d, /* 221 */
> +	0xfa, /* 222 */
> +	0xb7, /* 223 */
> +	0x5d, /* 224 */
> +	0x10, /* 225 */
> +	0xc7, /* 226 */
> +	0x8a, /* 227 */
> +	0x24, /* 228 */
> +	0x69, /* 229 */
> +	0xbe, /* 230 */
> +	0xf3, /* 231 */
> +	0xaf, /* 232 */
> +	0xe2, /* 233 */
> +	0x35, /* 234 */
> +	0x78, /* 235 */
> +	0xd6, /* 236 */
> +	0x9b, /* 237 */
> +	0x4c, /* 238 */
> +	0x01, /* 239 */
> +	0xf4, /* 240 */
> +	0xb9, /* 241 */
> +	0x6e, /* 242 */
> +	0x23, /* 243 */
> +	0x8d, /* 244 */
> +	0xc0, /* 245 */
> +	0x17, /* 246 */
> +	0x5a, /* 247 */
> +	0x06, /* 248 */
> +	0x4b, /* 249 */
> +	0x9c, /* 250 */
> +	0xd1, /* 251 */
> +	0x7f, /* 252 */
> +	0x32, /* 253 */
> +	0xe5, /* 254 */
> +	0xa8  /* 255 */
> +};
> +EXPORT_SYMBOL(sdw_crc8_lookup_msb);
> diff --git a/drivers/soundwire/crc8.h b/drivers/soundwire/crc8.h
> new file mode 100644
> index 000000000000..9a88d3866016
> --- /dev/null
> +++ b/drivers/soundwire/crc8.h
> @@ -0,0 +1,11 @@
> +/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
> +/* Copyright(c) 2024 Intel Corporation. */
> +
> +#ifndef __SDW_CRC8_H
> +#define __SDW_CRC8_H
> +
> +#define SDW_CRC8_SEED 0xFF
> +#define SDW_CRC8_POLY 0x4D
> +extern const u8 sdw_crc8_lookup_msb[CRC8_TABLE_SIZE];
> +
> +#endif /* __SDW_CRC8_H */
> -- 
> 2.39.2
> 

-- 
~Vinod

  reply	other threads:[~2023-12-18 12:01 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-07 22:29 [RFC PATCH 00/16] soundwire/ASoC: speed-up downloads with BTP/BRA protocol Pierre-Louis Bossart
2023-12-07 22:29 ` [RFC PATCH 01/16] Documentation: driver: add SoundWire BRA description Pierre-Louis Bossart
2023-12-07 23:29   ` Mark Brown
2023-12-08  0:56     ` Pierre-Louis Bossart
2023-12-08 21:49       ` Mark Brown
2023-12-19 16:50         ` Pierre-Louis Bossart
2023-12-19 16:53           ` Mark Brown
2023-12-19 17:08             ` Pierre-Louis Bossart
2023-12-20 15:16               ` Charles Keepax
2023-12-20 18:26                 ` Pierre-Louis Bossart
2023-12-20 18:28                   ` Mark Brown
2023-12-21  9:46                   ` Charles Keepax
2024-08-20  7:48     ` Pierre-Louis Bossart
2024-08-20 11:53       ` Mark Brown
2024-08-20 14:58         ` Pierre-Louis Bossart
2024-08-20 15:09           ` Mark Brown
2023-12-08 16:27   ` Charles Keepax
2023-12-08 18:45     ` Pierre-Louis Bossart
2023-12-08 18:55       ` Mark Brown
2023-12-18 11:40   ` Vinod Koul
2023-12-18 12:58     ` Pierre-Louis Bossart
2023-12-18 14:29       ` Charles Keepax
2023-12-18 16:33         ` Pierre-Louis Bossart
2023-12-21 14:45           ` Vinod Koul
2023-12-21 14:44         ` Vinod Koul
2023-12-21 14:44       ` Vinod Koul
2023-12-07 22:29 ` [RFC PATCH 02/16] soundwire: cadence: add BTP support for DP0 Pierre-Louis Bossart
2023-12-07 22:29 ` [RFC PATCH 03/16] soundwire: stream: extend sdw_alloc_stream() to take 'type' parameter Pierre-Louis Bossart
2023-12-07 22:29 ` [RFC PATCH 04/16] soundwire: extend sdw_stream_type to BPT Pierre-Louis Bossart
2023-12-07 22:29 ` [RFC PATCH 05/16] soundwire: stream: special-case the bus compute_params() routine Pierre-Louis Bossart
2023-12-07 22:29 ` [RFC PATCH 06/16] soundwire: stream: reuse existing code for BPT stream Pierre-Louis Bossart
2023-12-12 12:30   ` Charles Keepax
2023-12-18 10:45     ` Pierre-Louis Bossart
2023-12-07 22:29 ` [RFC PATCH 07/16] soundwire: bus: add API for BPT protocol Pierre-Louis Bossart
2023-12-12 12:19   ` Charles Keepax
2023-12-18 10:38     ` Pierre-Louis Bossart
2023-12-18 11:54   ` Vinod Koul
2023-12-18 13:12     ` Pierre-Louis Bossart
2023-12-18 14:57       ` Charles Keepax
2023-12-18 16:44         ` Pierre-Louis Bossart
2023-12-21 14:49       ` Vinod Koul
2023-12-07 22:29 ` [RFC PATCH 08/16] soundwire: bus: add bpt_stream pointer Pierre-Louis Bossart
2023-12-18 11:55   ` Vinod Koul
2023-12-18 13:20     ` Pierre-Louis Bossart
2023-12-21 14:39       ` Vinod Koul
2023-12-21 17:09         ` Pierre-Louis Bossart
2023-12-07 22:29 ` [RFC PATCH 09/16] soundwire: crc8: add constant table Pierre-Louis Bossart
2023-12-18 12:01   ` Vinod Koul [this message]
2023-12-18 13:26     ` Pierre-Louis Bossart
2023-12-21 14:42       ` Vinod Koul
2023-12-21 17:15         ` Pierre-Louis Bossart
2023-12-21 17:21           ` Vinod Koul
2023-12-07 22:29 ` [RFC PATCH 10/16] soundwire: cadence: add BTP/BRA helpers to format data Pierre-Louis Bossart
2023-12-07 22:29 ` [RFC PATCH 11/16] soundwire: intel_auxdevice: add indirection for BPT open/close/send_async/wait Pierre-Louis Bossart
2023-12-07 22:29 ` [RFC PATCH 12/16] ASoC: SOF: Intel: hda-sdw-bpt: add helpers for SoundWire BPT DMA Pierre-Louis Bossart
2023-12-07 22:29 ` [RFC PATCH 13/16] soundwire: intel: add BPT context definition Pierre-Louis Bossart
2023-12-07 22:29 ` [RFC PATCH 14/16] soundwire: intel_ace2x: add BPT open/close/send_async/wait Pierre-Louis Bossart
2023-12-07 22:29 ` [RFC PATCH 15/16] soundwire: debugfs: add interface for BPT/BRA transfers Pierre-Louis Bossart
2023-12-07 22:29 ` [RFC PATCH 16/16] ASoC: rt711-sdca: add DP0 support Pierre-Louis Bossart
2023-12-07 22:56 ` [RFC PATCH 00/16] soundwire/ASoC: speed-up downloads with BTP/BRA protocol Mark Brown
2023-12-07 23:06   ` Pierre-Louis Bossart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZYA0gKf3bZgY4X_s@matsya \
    --to=vkoul@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=ckeepax@opensource.cirrus.com \
    --cc=jack.yu@realtek.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=oder_chiou@realtek.com \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=rf@opensource.cirrus.com \
    --cc=shumingf@realtek.com \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=tiwai@suse.de \
    --cc=vijendar.mukunda@amd.com \
    --cc=vinod.koul@intel.com \
    --cc=yung-chuan.liao@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox