sound/oss/dmasound/dmasound_paula.c

Source file repositories/reference/linux-study-clean/sound/oss/dmasound/dmasound_paula.c

File Facts

System
Linux kernel
Corpus path
sound/oss/dmasound/dmasound_paula.c
Extension
.c
Size
19453 bytes
Lines
746
Domain
Driver Families
Bucket
sound/oss
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

while (count > 0) {
			if (get_user(*left++, userPtr++)
			    || get_user(*right++, userPtr++))
				return -EFAULT;
			count--;
		}
	}
	*frameUsed += used;
	return used;
}


    /*
     *  Copy and convert 8 bit data
     */

#define GENERATE_AMI_CT8(funcname, convsample)				\
static ssize_t funcname(const u_char __user *userPtr, size_t userCount,	\
			u_char frame[], ssize_t *frameUsed,		\
			ssize_t frameLeft)				\
{									\
	ssize_t count, used;						\
									\
	if (!dmasound.soft.stereo) {					\
		u_char *p = &frame[*frameUsed];				\
		count = min_t(size_t, userCount, frameLeft) & ~1;	\
		used = count;						\
		while (count > 0) {					\
			u_char data;					\
			if (get_user(data, userPtr++))			\
				return -EFAULT;				\
			*p++ = convsample(data);			\
			count--;					\
		}							\
	} else {							\
		u_char *left = &frame[*frameUsed>>1];			\
		u_char *right = left+write_sq_block_size_half;		\
		count = min_t(size_t, userCount, frameLeft)>>1 & ~1;	\
		used = count*2;						\
		while (count > 0) {					\
			u_char data;					\
			if (get_user(data, userPtr++))			\
				return -EFAULT;				\
			*left++ = convsample(data);			\
			if (get_user(data, userPtr++))			\
				return -EFAULT;				\
			*right++ = convsample(data);			\
			count--;					\
		}							\
	}								\
	*frameUsed += used;						\
	return used;							\
}

#define AMI_CT_ULAW(x)	(dmasound_ulaw2dma8[(x)])
#define AMI_CT_ALAW(x)	(dmasound_alaw2dma8[(x)])
#define AMI_CT_U8(x)	((x) ^ 0x80)

GENERATE_AMI_CT8(ami_ct_ulaw, AMI_CT_ULAW)
GENERATE_AMI_CT8(ami_ct_alaw, AMI_CT_ALAW)
GENERATE_AMI_CT8(ami_ct_u8, AMI_CT_U8)


    /*
     *  Copy and convert 16 bit data
     */

#define GENERATE_AMI_CT_16(funcname, convsample)			\
static ssize_t funcname(const u_char __user *userPtr, size_t userCount,	\
			u_char frame[], ssize_t *frameUsed,		\
			ssize_t frameLeft)				\
{									\
	const u_short __user *ptr = (const u_short __user *)userPtr;	\
	ssize_t count, used;						\
	u_short data;							\
									\
	if (!dmasound.soft.stereo) {					\
		u_char *high = &frame[*frameUsed>>1];			\
		u_char *low = high+write_sq_block_size_half;		\
		count = min_t(size_t, userCount, frameLeft)>>1 & ~1;	\
		used = count*2;						\
		while (count > 0) {					\
			if (get_user(data, ptr++))			\
				return -EFAULT;				\
			data = convsample(data);			\
			*high++ = data>>8;				\
			*low++ = (data>>2) & 0x3f;			\
			count--;					\
		}							\
	} else {							\

Annotation

Implementation Notes