Skip to contentSkip to conversation

Intel SST driver include headers

RFC PATCH In review Vinod Koul 4 participants 10 messages Jul 3, 2009 – Jul 7, 2009 Sound

lore
Share & tools
lore

Vinod Koul

author
#0 lore raw

RFC PATCH 3/13 Intel SST driver include headers

This patch adds the intel_sst.h header file that is places in the include folder for MAD driver (ALSA sound card driver for the platform given in later patches) to use. This file contains the definitions of interfaces exposed by the SST drivers along with the definitions of all the controls for the sound card to be used by MAD driver. intel_sst_ioctl.h - this file exposes the ioctls definitions for player/middleware to use. Many of the definitions are reuse from ALSA

new file: include/sound/intel_sst.h
new file: include/sound/intel_sst_ioctl.h

---
 include/sound/intel_sst.h       |  259 +++++++++++++++++++++++++++++
 include/sound/intel_sst_ioctl.h |  351 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 610 insertions(+), 0 deletions(-)
 create mode 100644 include/sound/intel_sst.h
 create mode 100644 include/sound/intel_sst_ioctl.h
include/sound/intel_sst.h new file +259 -0
new file mode 100644
index 0000000..c709390
@@ -0,0 +1,259 @@
+#ifndef __INTEL_SST_H__
+#define __INTEL_SST_H__
+/*
+ *  intel_sst.h - Intel SST Driver for audio engine
+ *
+ *  Copyright (C) 2008-09 	Intel Corporation
+ *  Authors:	Vinod Koul <[email protected]>
+ *  		Harsha Priya <[email protected]>
+ *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This driver exposes the audio engine functionalities to the ALSA
+ *	and middleware.
+ *  This file is shared between the SST and MAD drivers
+ */
+
+#ifndef CONFIG_SST_IPC_NOT_INCLUDED
+#include <asm/ipc_defs.h>
+#endif
+
+#define SST_CARD_NAMES "intel_mid_card"
+
+/*
+control list Pmic & Lpe
+*/
+/*Input controls*/
+
+enum sst_controls {
+	SST_SND_ALLOC =				0x1000,
+	SST_SND_PAUSE =				0x1001,
+	SST_SND_RESUME =			0x1002,
+	SST_SND_DROP =				0x1003,
+	SST_SND_FREE =				0x1004,
+	SST_SND_BUFFER_POINTER =		0x1005,
+	SST_SND_STREAM_INIT =			0x1006,
+	SST_MAX_CONTROLS =			0x1006,
+	SST_CONTROL_BASE =			0x1000,
+};
+
+struct pcm_stream_info {
+	int str_id;
+	void *mad_substream;
+	void (*period_elapsed) (void *mad_substream);
+	unsigned long buffer_ptr;
+};
+
+struct sst_control_list {
+	int control_element;
+	char *value;
+	struct sst_control_list *next_elem;
+};
+
+struct stream_buffer {
+	unsigned long	addr;
+	int		length;
+};
+
+
+/*
+SST debug print statement definition
+*/
+
+static inline long sst_get_time(void)
+{
+	 struct timeval t;
+	 do_gettimeofday(&t);
+	 return t.tv_usec;
+}
+
+#define _sst_printk_(level, format, arg...) \
+	printk(level "Time:%8ld::%8ld >> SST: %s %d " format, \
+		get_seconds(), sst_get_time(), __func__ , __LINE__, ## arg)
+
+#define sst_err(format, arg...) _sst_printk_(KERN_ERR, "ERR: " format, ## arg)
+#define sst_info(format, arg...) \
+	_sst_printk_(KERN_INFO, "INFO: " format, ## arg)
+
+#ifdef CONFIG_SST_DBG_PRINT
+#define sst_dbg(format, arg...) _sst_printk_(KERN_DEBUG, "DBG: " format, ## arg)
+#else
+#define sst_dbg(format, arg...) do {} while (0);
+#endif
+struct snd_pmic_ops {
+	int (*set_input_dev) (int value);
+	int (*get_input_dev) (int *value);
+
+	int (*set_output_dev) (int value);
+	int (*get_output_dev) (int *value);
+
+	int (*set_mute) (int dev_id, int value);
+	int (*get_mute) (int dev_id, int *value);
+
+	int (*set_vol) (int dev_id, int value);
+	int (*get_vol) (int dev_id, int *value);
+
+	int(*init_card) (void);
+	void (*set_pcm_params) (int sfreq, int word_size);
+
+	int (*init_card_capture) (void);
+
+};
+
+struct intel_sst_card_ops {
+	char *module_name;
+	int  vendor_id;
+	int (*control_set) (int control_element, void *value);
+	int (*send_buffer) (int str_id, struct stream_buffer *mad_buf);
+	struct snd_pmic_ops *scard_ops;
+};
+
+int register_sst_card(struct intel_sst_card_ops *card);
+void unregister_sst_card(struct intel_sst_card_ops *card);
+
+/*periphral interrupt interface*/
+enum lpe_periphral {
+	LPE_DMA = 1,
+	LPE_SSP0,
+	LPE_SSP1
+};
+
+/*modified for generic access*/
+struct sc_reg_access {
+	u16 reg_addr;
+	u8 value;
+	u8 mask;
+};
+enum sc_reg_access_type {
+	PMIC_READ = 0,
+	PMIC_WRITE,
+	PMIC_READ_MODIFY,
+};
+
+static inline int sst_sc_reg_access(struct sc_reg_access *sc_access,
+							int type, int num_val)
+{
+#ifndef CONFIG_SST_IPC_NOT_INCLUDED
+	int i, retval = 0, j = 0, k = 0, count = 0;
+	struct ipc_pmic_reg_data reg_data;
+	struct ipc_pmic_mod_reg_data pmic_mod_reg = {0};
+
+	reg_data.ioc = TRUE;
+	if (type == PMIC_WRITE) {
+		do {
+			int max_retries = 0;
+
+			if (num_val <= 4)
+				count = num_val;
+			else
+				count = 4;
+retry_write:
+			for (i = 0; i < count; i++, j++) {
+				reg_data.pmic_reg_data[i].
+				register_address = sc_access[j].reg_addr;
+
+				reg_data.pmic_reg_data[i].value =
+						sc_access[j].value;
+			}
+			reg_data.num_entries = count;
+			retval = ipc_pmic_register_write(&reg_data, 0);
+			if (E_NO_INTERRUPT_ON_IOC == retval &&
+					max_retries < 10) {
+				sst_err("write communcation needs retry\n");
+				max_retries++;
+				goto retry_write;
+			}
+			if (0 != retval) {
+				/*pmic communication fails*/
+				sst_err("pmic write failed \n");
+				return retval;
+			}
+			num_val -= count;
+		} while (num_val > 0);
+	} else if (type == PMIC_READ) {
+		do {
+			int max_retries = 0;
+			if (num_val <= 4)
+				count = num_val;
+			else
+				count = 4;
+retry_read:
+			for (i = 0; i < count; i++, j++)
+				reg_data.pmic_reg_data[i].register_address
+						= sc_access[j].reg_addr;
+			reg_data.num_entries = count;
+			retval = ipc_pmic_register_read(&reg_data);
+			if (E_NO_INTERRUPT_ON_IOC == retval &&
+						max_retries < 10) {
+				sst_err("read communcation needs retry\n");
+				max_retries++;
+				goto retry_read;
+			}
+			if (0 != retval) {
+				/*pmic communication fails*/
+				sst_err("pmic read failed \n");
+				return retval;
+			}
+
+			for (i = 0; i < count; i++, k++)
+				sc_access[k].value =
+					reg_data.pmic_reg_data[i].value;
+			num_val -= count;
+		} while (num_val > 0);
+	} else {
+		pmic_mod_reg.ioc = TRUE;
+		do {
+			int max_retries = 0;
+			if (num_val <= 4)
+				count = num_val;
+			else
+				count = 4;
+retry_readmod:
+			for (i = 0; i < count; i++, j++) {
+				pmic_mod_reg.pmic_mod_reg_data[i].
+				register_address = sc_access[j].reg_addr;
+				pmic_mod_reg.pmic_mod_reg_data[i].value =
+							sc_access[j].value;
+				pmic_mod_reg.pmic_mod_reg_data[i].bit_map =
+							sc_access[j].mask;
+			}
+			pmic_mod_reg.num_entries = count;
+			retval = ipc_pmic_register_read_modify(&pmic_mod_reg);
+			if (E_NO_INTERRUPT_ON_IOC == retval &&
+						max_retries < 10) {
+				sst_err("read/modify retry\n");
+				max_retries++;
+				goto retry_readmod;
+			}
+			if (0 != retval) {
+				/*pmic communication fails*/
+				sst_err("pmic read_modify failed \n");
+				return retval;
+			}
+			num_val -= count;
+		} while (num_val > 0);
+	}
+	return retval;
+#else
+	return 0;
+#endif
+}
+
+int lpe_mask_periphral_intr(enum lpe_periphral device);
+int lpe_unmask_periphral_intr(enum lpe_periphral device);
+int lpe_periphral_intr_status(enum lpe_periphral device, int *status);
+#endif /*__INTEL_SST_H__*/
include/sound/intel_sst_ioctl.h new file +351 -0

351 lines not on this page · raw message

Signature · 1 line
1.5.4.5
#1 lore raw

At Fri, 3 Jul 2009 12:32:25 +0530,

Quoted 26 lines · Vinod Koul

This patch adds the intel_sst.h header file that is places in the include folder for MAD driver (ALSA sound card driver for the platform given in later patches) to use. This file contains the definitions of interfaces exposed by the SST drivers along with the definitions of all the controls for the sound card to be used by MAD driver. intel_sst_ioctl.h - this file exposes the ioctls definitions for player/middleware to use. Many of the definitions are reuse from ALSA

new file: include/sound/intel_sst.h
new file: include/sound/intel_sst_ioctl.h

---
 include/sound/intel_sst.h       |  259 +++++++++++++++++++++++++++++
 include/sound/intel_sst_ioctl.h |  351 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 610 insertions(+), 0 deletions(-)
 create mode 100644 include/sound/intel_sst.h
 create mode 100644 include/sound/intel_sst_ioctl.h
include/sound/intel_sst.h new file +0 -0
new file mode 100644
index 0000000..c709390

(snip)

include/sound/intel_sst.h line 153

Quoted 7 lines
include/sound/intel_sst.h new file +7 -0
+static inline int sst_sc_reg_access(struct sc_reg_access *sc_access,
+							int type, int num_val)
+{
+#ifndef CONFIG_SST_IPC_NOT_INCLUDED
+	int i, retval = 0, j = 0, k = 0, count = 0;
+	struct ipc_pmic_reg_data reg_data;
+	struct ipc_pmic_mod_reg_data pmic_mod_reg = {0};

This is way too big as an inline function.

Quoted 21 lines
include/sound/intel_sst_ioctl.h new file +16 -0
new file mode 100644
index 0000000..848ea26
+
+enum sst_codec_types {
+/*  AUDIO/MUSIC	CODEC Type Definitions */
+	SST_CODEC_TYPE_UNKNOWN = 0,
+	SST_CODEC_TYPE_PCM,	/* Pass through Audio codec */
+	SST_CODEC_TYPE_MP3,
+	SST_CODEC_TYPE_MP24,
+	SST_CODEC_TYPE_AAC,
+	SST_CODEC_TYPE_AACP,
+	SST_CODEC_TYPE_eAACP,
+	SST_CODEC_TYPE_WMA9,
+	SST_CODEC_TYPE_WMA10,
+	SST_CODEC_TYPE_WMA10P,
+	SST_CODEC_TYPE_RA,
+	SST_CODEC_TYPE_DDAC3,
+	SST_CODEC_TYPE_STEREO_TRUE_HD,

include/sound/intel_sst_ioctl.h line 55

Quoted 10 lines
include/sound/intel_sst_ioctl.h new file +10 -0
+	SST_CODEC_TYPE_STEREO_HD_PLUS,
+
+	/*  VOICE CODEC Type Definitions */
+	SST_CODEC_TYPE_VOICE_PCM = 0x21, /* Pass through voice codec */
+	SRC = 0x64,
+	MIXER = 0x65,
+	DOWN_MIXER = 0x66,
+	VOLUME_CONTROL = 0x67,
+	OEM1 = 0xC8,
+	OEM2 = 0xC9,

These terms are too generic to be used as public definitions. Better to put a prefix.

include/sound/intel_sst_ioctl.h line 81

Quoted 11 lines
include/sound/intel_sst_ioctl.h new file +11 -0
+/* Firmware Version info */
+struct snd_sst_fw_version {
+	__u8 build;	/* build number*/
+	__u8 minor;	/* minor number*/
+	__u8 major;	/* major number*/
+	__u8 type; /* build type*/
+};
+
+/* Port info structure */
+struct snd_sst_port_info {
+	__u16 port_type;

Just wondering -- is there big-endian support?

include/sound/intel_sst_ioctl.h line 267

Quoted 8 lines
include/sound/intel_sst_ioctl.h new file +8 -0
+/* Target selection per device structure */
+struct snd_sst_slot_info {
+	__u8 mix_enable;		/* Mixer enable or disable */
+	__u8 device_type;
+	__u8 device_instance; 	/* 0, 1, 2 */
+	__u16 slot[2];
+	struct snd_sst_pmic_config pcm_params;
+	enum snd_sst_target_type type;

Better to use another type with a strict size instead of enum.

include/sound/intel_sst_ioctl.h line 290

Quoted 4 lines
include/sound/intel_sst_ioctl.h new file +4 -0
+struct snd_sst_vol {
+	unsigned int	stream_id;
+	int		volume;
+	unsigned long	ramp_duration;

Are you sure to use long?
Long can be different between 32 and 64bit architectures.

include/sound/intel_sst_ioctl.h line 309

Quoted 5 lines
include/sound/intel_sst_ioctl.h new file +5 -0
+struct snd_sst_buff_entry {
+	union {
+		void *user;
+		unsigned int offset;
+	} buffer;

Is it OK?
The pointer and int can be different sizes.

Takashi

#2 lore raw
Quoted 5 lines
Quoted 5 lines
include/sound/intel_sst_ioctl.h new file +5 -0
+/* Firmware Version info */
+struct snd_sst_fw_version {
+	__u8 build;	/* build number*/
+	__u8 minor;	/* minor number*/
+	__u8 major;	/* major number*/
Quoted 8 lines

include/sound/intel_sst_ioctl.h line 81

Quoted 6 lines
include/sound/intel_sst_ioctl.h new file +6 -0
+	__u8 type; /* build type*/
+};
+
+/* Port info structure */
+struct snd_sst_port_info {
+	__u16 port_type;

Just wondering -- is there big-endian support?

We have not tested this on big-endian, Could you tell us that should we make it endian safe?

Quoted 8 lines

include/sound/intel_sst_ioctl.h line 290

Quoted 5 lines
include/sound/intel_sst_ioctl.h new file +4 -0
+struct snd_sst_vol {
+	unsigned int	stream_id;
+	int		volume;
+	unsigned long	ramp_duration;

Are you sure to use long?
Long can be different between 32 and 64bit architectures.

We will change it to u32.

Quoted 9 lines

include/sound/intel_sst_ioctl.h line 309

Quoted 6 lines
include/sound/intel_sst_ioctl.h new file +5 -0
+struct snd_sst_buff_entry {
+	union {
+		void *user;
+		unsigned int offset;
+	} buffer;

Is it OK?
The pointer and int can be different sizes.

void* user - is the pointer to the buffer
unsigned int offset - is the offset inside the buffer area.
Not sure if I understand your comment. Please let us know if there is any issue you see with this structure.

Thanks,
Harsha

#3 lore raw

At Tue, 7 Jul 2009 11:33:23 +0530,

Quoted 14 lines · Priya
Quoted 14 lines

include/sound/intel_sst_ioctl.h line 81

Quoted 12 lines
include/sound/intel_sst_ioctl.h new file +11 -0
+/* Firmware Version info */
+struct snd_sst_fw_version {
+	__u8 build;	/* build number*/
+	__u8 minor;	/* minor number*/
+	__u8 major;	/* major number*/
+	__u8 type; /* build type*/
+};
+
+/* Port info structure */
+struct snd_sst_port_info {
+	__u16 port_type;

Just wondering -- is there big-endian support?

Quoted 2 lines

We have not tested this on big-endian, Could you tell us that should we make it endian safe?

When a field is more than one byte, you'd need endian conversion at read/write. I didn't find it thus I suspected it.

Quoted 18 lines
Quoted 7 lines

include/sound/intel_sst_ioctl.h line 290

Quoted 4 lines
include/sound/intel_sst_ioctl.h new file +4 -0
+struct snd_sst_vol {
+	unsigned int	stream_id;
+	int		volume;
+	unsigned long	ramp_duration;

Are you sure to use long?
Long can be different between 32 and 64bit architectures.

We will change it to u32.

Quoted 9 lines

include/sound/intel_sst_ioctl.h line 309

Quoted 6 lines
include/sound/intel_sst_ioctl.h new file +5 -0
+struct snd_sst_buff_entry {
+	union {
+		void *user;
+		unsigned int offset;
+	} buffer;

Is it OK?
The pointer and int can be different sizes.

Quoted 4 lines

void* user - is the pointer to the buffer
unsigned int offset - is the offset inside the buffer area. Not sure if I understand your comment. Please let us know if there is any issue you see with this structure.

A pointer can be 64bit while offset is always 32bit.
If they don't have to share the same space, why need to be a union?

thanks,

Takashi

#4 lore raw
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines

include/sound/intel_sst_ioctl.h line 81

Quoted 12 lines
include/sound/intel_sst_ioctl.h new file +11 -0
+/* Firmware Version info */
+struct snd_sst_fw_version {
+	__u8 build;	/* build number*/
+	__u8 minor;	/* minor number*/
+	__u8 major;	/* major number*/
+	__u8 type; /* build type*/
+};
+
+/* Port info structure */
+struct snd_sst_port_info {
+	__u16 port_type;

Just wondering -- is there big-endian support?

Quoted 5 lines
Quoted 2 lines

We have not tested this on big-endian, Could you tell us that should we make it endian safe?

When a field is more than one byte, you'd need endian conversion at read/write. I didn't find it thus I suspected it.

So, does it look safe to keep the code as such? We are using the bit field in union only for ease of setting/getting bit values and not for communication.

Quoted 20 lines
Quoted 20 lines
Quoted 9 lines

include/sound/intel_sst_ioctl.h line 290

Quoted 6 lines
include/sound/intel_sst_ioctl.h new file +4 -0
+struct snd_sst_vol {
+	unsigned int	stream_id;
+	int		volume;
+	unsigned long	ramp_duration;

Are you sure to use long?
Long can be different between 32 and 64bit architectures.

We will change it to u32.

Quoted 9 lines

include/sound/intel_sst_ioctl.h line 309

Quoted 6 lines
include/sound/intel_sst_ioctl.h new file +5 -0
+struct snd_sst_buff_entry {
+	union {
+		void *user;
+		unsigned int offset;
+	} buffer;

Is it OK?
The pointer and int can be different sizes.

Quoted 7 lines
Quoted 4 lines

void* user - is the pointer to the buffer
unsigned int offset - is the offset inside the buffer area. Not sure if I understand your comment. Please let us know if there is any issue you see with this structure.

A pointer can be 64bit while offset is always 32bit.
If they don't have to share the same space, why need to be a union?

I think I will give more clear explanation here before this structure declaration. I know its confusing. Basically we support both mmap and user buffers. When user buffers are passed to the driver then void *user field is used and when mmap buffers are passed to the driver, the offset in the mmap buffer is passed in this structure. Either mmap buffer's offset or user buffer address will be used and not both.

Thanks,
Harsha

#5 lore raw

At Tue, 7 Jul 2009 11:59:37 +0530,

Quoted 15 lines · Priya
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines

include/sound/intel_sst_ioctl.h line 81

Quoted 13 lines
include/sound/intel_sst_ioctl.h new file +11 -0
+/* Firmware Version info */
+struct snd_sst_fw_version {
+	__u8 build;	/* build number*/
+	__u8 minor;	/* minor number*/
+	__u8 major;	/* major number*/
+	__u8 type; /* build type*/
+};
+
+/* Port info structure */
+struct snd_sst_port_info {
+	__u16 port_type;

Just wondering -- is there big-endian support?

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

We have not tested this on big-endian, Could you tell us that should we make it endian safe?

When a field is more than one byte, you'd need endian conversion at read/write. I didn't find it thus I suspected it.

So, does it look safe to keep the code as such?

Unlikely...

Quoted 3 lines

We are using the bit
field in union only for ease of setting/getting bit values and not for communication.

What I meant is the data used for the communication. Not the communication method itself. Here the communication includes the firmware data, too.

If the data is created by the driver locally and used only inside the driver, then it's fine. Otherwise, you shouldn't use bit fields.

Quoted 26 lines
Quoted 19 lines
Quoted 19 lines
Quoted 8 lines

include/sound/intel_sst_ioctl.h line 290

Quoted 5 lines
include/sound/intel_sst_ioctl.h new file +4 -0
+struct snd_sst_vol {
+	unsigned int	stream_id;
+	int		volume;
+	unsigned long	ramp_duration;

Are you sure to use long?
Long can be different between 32 and 64bit architectures.

We will change it to u32.

Quoted 9 lines

include/sound/intel_sst_ioctl.h line 309

Quoted 6 lines
include/sound/intel_sst_ioctl.h new file +5 -0
+struct snd_sst_buff_entry {
+	union {
+		void *user;
+		unsigned int offset;
+	} buffer;

Is it OK?
The pointer and int can be different sizes.

Quoted 7 lines
Quoted 4 lines

void* user - is the pointer to the buffer
unsigned int offset - is the offset inside the buffer area. Not sure if I understand your comment. Please let us know if there is any issue you see with this structure.

A pointer can be 64bit while offset is always 32bit.
If they don't have to share the same space, why need to be a union?

Quoted 7 lines

I think I will give more clear explanation here before this structure declaration. I know its confusing. Basically we support both mmap and user buffers. When user buffers are passed to the driver then void *user field is used and when mmap buffers are passed to the driver, the offset in the mmap buffer is passed in this structure. Either mmap buffer's offset or user buffer address will be used and not both.

Then avoid union unless you really need it (i.e. the tight memory packing). In general, union is often a cause of troubles. As a simple example against union, imagine that you put a debug print of this struct...

thanks,

Takashi

#6 lore raw
Quoted 28 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines

include/sound/intel_sst_ioctl.h line 81

Quoted 13 lines
include/sound/intel_sst_ioctl.h new file +11 -0
+/* Firmware Version info */
+struct snd_sst_fw_version {
+	__u8 build;	/* build number*/
+	__u8 minor;	/* minor number*/
+	__u8 major;	/* major number*/
+	__u8 type; /* build type*/
+};
+
+/* Port info structure */
+struct snd_sst_port_info {
+	__u16 port_type;

Just wondering -- is there big-endian support?

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

We have not tested this on big-endian, Could you tell us that should we make it endian safe?

When a field is more than one byte, you'd need endian conversion at read/write. I didn't find it thus I suspected it.

So, does it look safe to keep the code as such?

Unlikely...

Quoted 3 lines

We are using the bit
field in union only for ease of setting/getting bit values and not for communication.

Quoted 6 lines

What I meant is the data used for the communication. Not the communication method itself. Here the communication includes the firmware data, too.

If the data is created by the driver locally and used only inside the driver, then it's fine. Otherwise, you shouldn't use bit fields.

Yes. This is the case. The data is generated internally to the driver and used inside the driver only. When the data is communicated to the firmware, only the 32bit register is passed and the bit fields are not used.

Thanks,
Harsha

#7 lore raw

At Tue, 7 Jul 2009 12:21:00 +0530,

Quoted 33 lines · Priya
Quoted 33 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 4 lines
(quoted diff) +1 -0
+/* Firmware Version info */

Review

Quoted 10 lines
(quoted diff) +10 -0
+struct snd_sst_fw_version {
+	__u8 build;	/* build number*/
+	__u8 minor;	/* minor number*/
+	__u8 major;	/* major number*/
+	__u8 type; /* build type*/
+};
+
+/* Port info structure */
+struct snd_sst_port_info {
+	__u16 port_type;

Just wondering -- is there big-endian support?

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

We have not tested this on big-endian, Could you tell us that should we make it endian safe?

When a field is more than one byte, you'd need endian conversion at read/write. I didn't find it thus I suspected it.

So, does it look safe to keep the code as such?

Unlikely...

Quoted 3 lines

We are using the bit
field in union only for ease of setting/getting bit values and not for communication.

What I meant is the data used for the communication. Not the communication method itself. Here the communication includes the firmware data, too.

Quoted 8 lines
Quoted 2 lines

If the data is created by the driver locally and used only inside the driver, then it's fine. Otherwise, you shouldn't use bit fields.

Yes. This is the case. The data is generated internally to the driver and used inside the driver only. When the data is communicated to the firmware, only the 32bit register is passed and the bit fields are not used.

Hm, then I misread the code too quickly.
I thought the 32bit data is generated from the bit fields in a way depending on the architecture.

Takashi

#8 lore raw
In reply to Vinod Koul

include/sound/intel_sst.h line 98

Quoted 2 lines · Vinod Koul
include/sound/intel_sst.h new file +2 -0
+struct snd_pmic_ops {
+	int (*set_input_dev) (int value);

I'm not sure what pmic is an abbreviation for but I worry that using this abbreviation is likely to cause confusion - PMIC normally refers to a Power Management IC in embedded applications.

#9 lore raw
Quoted 10 lines

-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Friday, July 03, 2009 5:00 PM
To: Koul, Vinod
Cc: [email protected]; Harsha, Priya
Subject: Re: [alsa-devel] [PATCH] [RFC 3/13] Intel SST driver include headers

Quoted 8 lines

include/sound/intel_sst.h line 98

Quoted 2 lines · Vinod Koul
include/sound/intel_sst.h new file +2 -0
+struct snd_pmic_ops {
+	int (*set_input_dev) (int value);

I'm not sure what pmic is an abbreviation for but I worry that using this abbreviation is likely to cause confusion - PMIC normally refers to a Power Management IC in embedded applications.

PMIC is indeed Power management IC. (In the platform, sound card components are embedded inside the PMIC.) I shall change the name to sound card to avoid confusion.