mpu_port - 0x300 (default),0x310,0x320,0x330, -1 (diable)
fm_port - 0x388 (default), -1 (disable)
+ soft_ac3 - Sofware-conversion of raw SPDIF packets (model 033 only)
+ (default = 1)
Module supports autoprobe and multiple chips (max 8).
- The first DAC supports U8 and S16LE formats, while the second DAC
supports only S16LE.
-- The second DAC supports only two channel stereo.
+- The seconde DAC supports only two channel stereo.
Please note that the CM8x38 DAC doesn't support continuous playback
rate but only fixed rates: 5512, 8000, 11025, 16000, 22050, 32000,
"-MC" such like "CMI8738-MC6". You can check this name from
/proc/asound/cards.
-When the 4/6-ch output is enabled, the front DAC accepts up to 6 (or
-4) channels. This is different from the dual DACs described in the
-previous section. While the dual DAC supports two different rates or
+When the 4/6-ch output is enabled, the second DAC accepts up to 6 (or
+4) channels. While the dual DAC supports two different rates or
formats, the 4/6-ch playback supports only the same condition for all
-channels.
+channels. Since the multi-channel playback mode uses both DACs, you
+cannot operate with full-duplex.
-For using 4/6 channel playback, you need to specify the PCM channels
-as you like and set the format S16LE. For example, for playback with
-4 channels,
+The 4.0 and 5.1 modes are defined as the pcm "surround40" and "surround51"
+in alsa-lib. For example, you can play a WAV file with 6 channels like
+
+ % aplay -Dsurround51 sixchannels.wav
+
+For programmin the 4/6 channel playback, you need to specify the PCM
+channels as you like and set the format S16LE. For example, for playback
+with 4 channels,
snd_pcm_hw_params_set_access(pcm, hw, SND_PCM_ACCESS_RW_INTERLEAVED);
// or mmap if you like
"IEC958 Loop". The switches are resumed after closing the SPDIF PCM
device automatically to the previous state.
+On the model 033, AC3 is implemented by the software conversion in
+the driver. This prevents the mmap support. If you need mmap
+support, pass the "soft_ac3=0" module option. This doesn't matter
+on the newer models.
+
ANALOG MIXER INTERFACE
----------------------
void snd_dma_program(unsigned long dma, unsigned long addr, unsigned int size, unsigned short mode);
void snd_dma_disable(unsigned long dma);
-unsigned int snd_dma_residue(unsigned long dma);
+unsigned int snd_dma_pointer(unsigned long dma, unsigned int size);
/* misc.c */
insure that the fractional error is always
positive)
*/
- long outTripletsPerFrame;
+ u32 outTripletsPerFrame;
/* 16b.16b integer.frac accumulated number of
output triplets since the start of group
*/
- long accumOutTriplets;
+ u32 accumOutTriplets;
} mix2_ostream_spb_t;
/* SCB for Timing master algorithm */
u32 vdec_input_buf_strm_config;
/* inputBufStrmConfig: rsConfig for the input buffer to the decimator
(buffer size = 64 dwords) */
- long vdec_coef_increment;
+ u32 vdec_coef_increment;
/* coefIncrement = - 128.0 / decimationFactor (as a 32Q15 number) */
- long vdec_accumphi;
+ u32 vdec_accumphi;
/* accumPhi: accumulated fractional phase increment (6.26) */
u16 vdec_exp_vol_change_rate;
u16 spdif_input_volume_left;
/* spdif channel status,
left right and user validity bits */
- int spdif_csuv_default;
- int spdif_csuv_stream;
+ unsigned int spdif_csuv_default;
+ unsigned int spdif_csuv_stream;
/* SPDIF input sample rate converter */
dsp_scb_descriptor_t * spdif_in_src;
typedef int (*snd_mixer_oss_put_volume_t)(snd_mixer_oss_file_t *fmixer, snd_mixer_oss_slot_t *chn, int left, int right);
typedef int (*snd_mixer_oss_get_recsrc_t)(snd_mixer_oss_file_t *fmixer, snd_mixer_oss_slot_t *chn, int *active);
typedef int (*snd_mixer_oss_put_recsrc_t)(snd_mixer_oss_file_t *fmixer, snd_mixer_oss_slot_t *chn, int active);
-typedef int (*snd_mixer_oss_get_recsrce_t)(snd_mixer_oss_file_t *fmixer, int *active_index);
-typedef int (*snd_mixer_oss_put_recsrce_t)(snd_mixer_oss_file_t *fmixer, int active_index);
+typedef int (*snd_mixer_oss_get_recsrce_t)(snd_mixer_oss_file_t *fmixer, unsigned int *active_index);
+typedef int (*snd_mixer_oss_put_recsrce_t)(snd_mixer_oss_file_t *fmixer, unsigned int active_index);
#define SNDRV_OSS_MAX_MIXERS 32
INLINE void snd_mask_set_range(snd_mask_t *mask, unsigned int from, unsigned int to)
{
- int i;
+ unsigned int i;
assert(to <= SNDRV_MASK_BITS && from <= to);
for (i = from; i <= to; i++)
mask->bits[MASK_OFS(i)] |= MASK_BIT(i);
INLINE void snd_mask_reset_range(snd_mask_t *mask, unsigned int from, unsigned int to)
{
- int i;
+ unsigned int i;
assert(to <= SNDRV_MASK_BITS && from <= to);
for (i = from; i <= to; i++)
mask->bits[MASK_OFS(i)] &= ~MASK_BIT(i);
/* port attach/detach */
int snd_seq_event_port_attach(int client, snd_seq_port_callback_t *pcbp,
- int cap, int type, char *portname);
+ int cap, int type, int midi_channels, char *portname);
int snd_seq_event_port_detach(int client, int port);
#endif /* __SOUND_SEQ_KERNEL_H */
static inline unsigned long _snd_magic_value(void *obj)
{
- return obj == NULL ? -1 : *(((unsigned long *)obj) - 1);
+ return obj == NULL ? (unsigned long)-1 : *(((unsigned long *)obj) - 1);
}
static inline int _snd_magic_bad(void *obj, unsigned long magic)
#define SNDRV_TIMER_HW_STOP 0x00000002 /* call stop before start */
#define SNDRV_TIMER_HW_SLAVE 0x00000004 /* only slave timer (variable resolution) */
#define SNDRV_TIMER_HW_FIRST 0x00000008 /* first tick can be incomplete */
+#define SNDRV_TIMER_HW_TASKLET 0x00000010 /* timer is called from tasklet */
-#define SNDRV_TIMER_IFLG_SLAVE 0x00000001
-#define SNDRV_TIMER_IFLG_RUNNING 0x00000002
-#define SNDRV_TIMER_IFLG_START 0x00000004
-#define SNDRV_TIMER_IFLG_AUTO 0x00000008 /* auto restart */
+#define SNDRV_TIMER_IFLG_SLAVE 0x00000001
+#define SNDRV_TIMER_IFLG_RUNNING 0x00000002
+#define SNDRV_TIMER_IFLG_START 0x00000004
+#define SNDRV_TIMER_IFLG_AUTO 0x00000008 /* auto restart */
+#define SNDRV_TIMER_IFLG_FAST 0x00000010 /* fast callback (do not use tasklet) */
+#define SNDRV_TIMER_IFLG_CALLBACK 0x00000020 /* timer callback is active */
-#define SNDRV_TIMER_FLG_SYSTEM 0x00000001 /* system timer */
-#define SNDRV_TIMER_FLG_CHANGE 0x00000002
-#define SNDRV_TIMER_FLG_RESCHED 0x00000004 /* need reschedule */
+#define SNDRV_TIMER_FLG_CHANGE 0x00000001
+#define SNDRV_TIMER_FLG_RESCHED 0x00000002 /* need reschedule */
-typedef void (*snd_timer_callback_t) (snd_timer_instance_t * timeri, unsigned long ticks, unsigned long resolution, void *data);
+typedef void (*snd_timer_callback_t) (snd_timer_instance_t * timeri, unsigned long ticks, unsigned long resolution);
struct _snd_timer_hardware {
/* -- must be filled with low-level driver */
struct list_head device_list;
struct list_head open_list_head;
struct list_head active_list_head;
+ struct list_head ack_list_head;
+ struct list_head sack_list_head; /* slow ack list head */
+ struct tasklet_struct task_queue;
};
struct _snd_timer_instance {
void (*private_free) (snd_timer_instance_t *ti);
snd_timer_callback_t callback;
void *callback_data;
- unsigned long ticks;
- unsigned long cticks;
+ unsigned long ticks; /* auto-load ticks when expired */
+ unsigned long cticks; /* current ticks */
+ unsigned long pticks; /* accumulated ticks for callback */
+ unsigned long resolution; /* current resolution for tasklet */
unsigned long lost; /* lost ticks */
snd_timer_slave_class_t slave_class;
unsigned int slave_id;
struct list_head open_list;
struct list_head active_list;
+ struct list_head ack_list;
struct list_head slave_list_head;
struct list_head slave_active_head;
snd_timer_instance_t *master;
- atomic_t in_use; /* don't free */
};
/*
extern unsigned long snd_timer_resolution(snd_timer_instance_t * timeri);
extern int snd_timer_start(snd_timer_instance_t * timeri, unsigned int ticks);
extern int snd_timer_stop(snd_timer_instance_t * timeri);
-extern int snd_timer_del(snd_timer_instance_t * timeri);
extern int snd_timer_continue(snd_timer_instance_t * timeri);
extern void snd_timer_interrupt(snd_timer_t * timer, unsigned long ticks_left);
-/* include/version.h. Generated automatically by configure. */
-#define CONFIG_SND_VERSION "0.9.0rc6"
-#define CONFIG_SND_DATE " (Tue Jan 28 12:17:23 2003 UTC)"
+/* include/version.h. Generated by configure. */
+#define CONFIG_SND_VERSION "0.9.0rc7"
+#define CONFIG_SND_DATE " (Sat Feb 08 17:33:25 2003 UTC)"
{
snd_device_t *dev;
struct list_head *list;
- int err, range_low, range_high;
+ int err;
+ unsigned int range_low, range_high;
snd_assert(card != NULL, return -ENXIO);
range_low = cmd * SNDRV_DEV_TYPE_RANGE_SIZE;
if ((err = snd_register_device(SNDRV_DEVICE_TYPE_HWDEP,
hwdep->card, hwdep->device,
&snd_hwdep_reg, name)) < 0) {
- snd_printk(KERN_ERR "unable to register hardware dependent device %i:%i\n",
+ snd_printk(KERN_ERR "unable to register hardware dependant device %i:%i\n",
hwdep->card->number, hwdep->device);
snd_hwdep_devices[idx] = NULL;
up(®ister_mutex);
while (--len > 0) {
c = *buffer->curr++;
if (c == '\n') {
- if ((buffer->curr - buffer->buffer) >= buffer->size) {
+ if ((buffer->curr - buffer->buffer) >= (long)buffer->size) {
buffer->stop = 1;
}
break;
}
*line++ = c;
- if ((buffer->curr - buffer->buffer) >= buffer->size) {
+ if ((buffer->curr - buffer->buffer) >= (long)buffer->size) {
buffer->stop = 1;
break;
}
}
while (c != '\n' && !buffer->stop) {
c = *buffer->curr++;
- if ((buffer->curr - buffer->buffer) >= buffer->size) {
+ if ((buffer->curr - buffer->buffer) >= (long)buffer->size) {
buffer->stop = 1;
}
}
id++;
}
id = card->id;
- while (*spos != '\0' && id - card->id < sizeof(card->id) - 1) {
+ while (*spos != '\0' && (size_t)(id - card->id) < sizeof(card->id) - 1) {
if (isalnum(*spos))
*id++ = *spos;
spos++;
len = strlen(id);
if (idx_flag)
id[len-1]++;
- else if (len <= sizeof(card->id) - 3) {
+ else if ((size_t)len <= sizeof(card->id) - 3) {
strcat(id, "_1");
idx_flag++;
} else {
spos = id + len - 2;
- if (len <= sizeof(card->id) - 2)
+ if ((size_t)len <= sizeof(card->id) - 2)
spos++;
*spos++ = '_';
*spos++ = '1';
}
+/*
+ * compatible wrapper
+ */
+int snd_ioctl32_compat(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *filp)
+{
+ if (! filp->f_op || ! filp->f_op->ioctl)
+ return -ENOTTY;
+ return filp->f_op->ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
+}
+
+
/*
* Controls
*/
static struct ioctl32_mapper control_mappers[] = {
/* controls (without rawmidi, hwdep, timer releated ones) */
- { SNDRV_CTL_IOCTL_PVERSION, NULL },
- { SNDRV_CTL_IOCTL_CARD_INFO , NULL },
+ MAP_COMPAT(SNDRV_CTL_IOCTL_PVERSION),
+ MAP_COMPAT(SNDRV_CTL_IOCTL_CARD_INFO),
{ SNDRV_CTL_IOCTL_ELEM_LIST32, AP(ctl_elem_list) },
{ SNDRV_CTL_IOCTL_ELEM_INFO32, AP(ctl_elem_info) },
{ SNDRV_CTL_IOCTL_ELEM_READ32, AP(ctl_elem_read) },
{ SNDRV_CTL_IOCTL_ELEM_WRITE32, AP(ctl_elem_write) },
- { SNDRV_CTL_IOCTL_ELEM_LOCK, NULL },
- { SNDRV_CTL_IOCTL_ELEM_UNLOCK, NULL },
- { SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS, NULL },
- { SNDRV_CTL_IOCTL_HWDEP_INFO, NULL },
- { SNDRV_CTL_IOCTL_HWDEP_NEXT_DEVICE, NULL },
- { SNDRV_CTL_IOCTL_PCM_NEXT_DEVICE, NULL },
- { SNDRV_CTL_IOCTL_PCM_INFO, NULL },
- { SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE, NULL },
- { SNDRV_CTL_IOCTL_POWER, NULL },
- { SNDRV_CTL_IOCTL_POWER_STATE, NULL },
+ MAP_COMPAT(SNDRV_CTL_IOCTL_ELEM_LOCK),
+ MAP_COMPAT(SNDRV_CTL_IOCTL_ELEM_UNLOCK),
+ MAP_COMPAT(SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS),
+ MAP_COMPAT(SNDRV_CTL_IOCTL_HWDEP_INFO),
+ MAP_COMPAT(SNDRV_CTL_IOCTL_HWDEP_NEXT_DEVICE),
+ MAP_COMPAT(SNDRV_CTL_IOCTL_PCM_NEXT_DEVICE),
+ MAP_COMPAT(SNDRV_CTL_IOCTL_PCM_INFO),
+ MAP_COMPAT(SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE),
+ MAP_COMPAT(SNDRV_CTL_IOCTL_POWER),
+ MAP_COMPAT(SNDRV_CTL_IOCTL_POWER_STATE),
{ 0 }
};
oldseg = get_fs();\
set_fs(KERNEL_DS);\
err = file->f_op->ioctl(file->f_dentry->d_inode, file, native_ctl, (unsigned long)&data);\
+ set_fs(oldseg);\
if (err < 0) \
return err;\
if (native_ctl & (_IOC_READ << _IOC_DIRSHIFT)) {\
oldseg = get_fs();\
set_fs(KERNEL_DS);\
err = file->f_op->ioctl(file->f_dentry->d_inode, file, native_ctl, (unsigned long)data);\
+ set_fs(oldseg);\
if (err < 0) \
goto __end;\
err = 0;\
return _snd_ioctl32_##type(fd, cmd, arg, file, native_ctl);\
}
+#define MAP_COMPAT(ctl) { ctl, snd_ioctl32_compat }
struct ioctl32_mapper {
unsigned int cmd;
int registered;
};
+int snd_ioctl32_compat(unsigned int, unsigned int, unsigned long, struct file *);
+
int snd_ioctl32_register(struct ioctl32_mapper *mappers);
void snd_ioctl32_unregister(struct ioctl32_mapper *mappers);
#define CVT_sndrv_pcm_hw_params()\
{\
- int i;\
+ unsigned int i;\
COPY(flags);\
for (i = 0; i < numberof(dst->masks); i++)\
COPY(masks[i]);\
};
struct ioctl32_mapper pcm_mappers[] = {
- { SNDRV_PCM_IOCTL_PVERSION, NULL },
- { SNDRV_PCM_IOCTL_INFO, NULL },
+ MAP_COMPAT(SNDRV_PCM_IOCTL_PVERSION),
+ MAP_COMPAT(SNDRV_PCM_IOCTL_INFO),
{ SNDRV_PCM_IOCTL_HW_REFINE32, AP(pcm_hw_refine) },
{ SNDRV_PCM_IOCTL_HW_PARAMS32, AP(pcm_hw_params) },
{ SNDRV_PCM_IOCTL_HW_REFINE_OLD32, AP(pcm_hw_refine_old) },
{ SNDRV_PCM_IOCTL_HW_PARAMS_OLD32, AP(pcm_hw_params_old) },
- { SNDRV_PCM_IOCTL_HW_FREE, NULL },
+ MAP_COMPAT(SNDRV_PCM_IOCTL_HW_FREE),
{ SNDRV_PCM_IOCTL_SW_PARAMS32, AP(pcm_sw_params) },
{ SNDRV_PCM_IOCTL_STATUS32, AP(pcm_status) },
{ SNDRV_PCM_IOCTL_DELAY32, AP(pcm_delay) },
{ SNDRV_PCM_IOCTL_CHANNEL_INFO32, AP(pcm_channel_info) },
- { SNDRV_PCM_IOCTL_PREPARE, NULL },
- { SNDRV_PCM_IOCTL_RESET, NULL },
- { SNDRV_PCM_IOCTL_START, NULL },
- { SNDRV_PCM_IOCTL_DROP, NULL },
- { SNDRV_PCM_IOCTL_DRAIN, NULL },
- { SNDRV_PCM_IOCTL_PAUSE, NULL },
+ MAP_COMPAT(SNDRV_PCM_IOCTL_PREPARE),
+ MAP_COMPAT(SNDRV_PCM_IOCTL_RESET),
+ MAP_COMPAT(SNDRV_PCM_IOCTL_START),
+ MAP_COMPAT(SNDRV_PCM_IOCTL_DROP),
+ MAP_COMPAT(SNDRV_PCM_IOCTL_DRAIN),
+ MAP_COMPAT(SNDRV_PCM_IOCTL_PAUSE),
{ SNDRV_PCM_IOCTL_REWIND32, AP(pcm_rewind) },
- { SNDRV_PCM_IOCTL_RESUME, NULL },
- { SNDRV_PCM_IOCTL_XRUN, NULL },
+ MAP_COMPAT(SNDRV_PCM_IOCTL_RESUME),
+ MAP_COMPAT(SNDRV_PCM_IOCTL_XRUN),
{ SNDRV_PCM_IOCTL_WRITEI_FRAMES32, AP(pcm_writei) },
{ SNDRV_PCM_IOCTL_READI_FRAMES32, AP(pcm_readi) },
{ SNDRV_PCM_IOCTL_WRITEN_FRAMES32, AP(pcm_writen) },
{ SNDRV_PCM_IOCTL_READN_FRAMES32, AP(pcm_readn) },
- { SNDRV_PCM_IOCTL_LINK, NULL },
- { SNDRV_PCM_IOCTL_UNLINK, NULL },
+ MAP_COMPAT(SNDRV_PCM_IOCTL_LINK),
+ MAP_COMPAT(SNDRV_PCM_IOCTL_UNLINK),
{ 0 },
};
};
struct ioctl32_mapper rawmidi_mappers[] = {
- { SNDRV_RAWMIDI_IOCTL_PVERSION, NULL },
- { SNDRV_RAWMIDI_IOCTL_INFO, NULL },
+ MAP_COMPAT(SNDRV_RAWMIDI_IOCTL_PVERSION),
+ MAP_COMPAT(SNDRV_RAWMIDI_IOCTL_INFO),
{ SNDRV_RAWMIDI_IOCTL_PARAMS32, AP(rawmidi_params) },
{ SNDRV_RAWMIDI_IOCTL_STATUS32, AP(rawmidi_status) },
- { SNDRV_RAWMIDI_IOCTL_DROP, NULL },
- { SNDRV_RAWMIDI_IOCTL_DRAIN, NULL },
+ MAP_COMPAT(SNDRV_RAWMIDI_IOCTL_DROP),
+ MAP_COMPAT(SNDRV_RAWMIDI_IOCTL_DRAIN),
- { SNDRV_CTL_IOCTL_RAWMIDI_NEXT_DEVICE, NULL },
- { SNDRV_CTL_IOCTL_RAWMIDI_INFO, NULL },
- { SNDRV_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE, NULL },
+ MAP_COMPAT(SNDRV_CTL_IOCTL_RAWMIDI_NEXT_DEVICE),
+ MAP_COMPAT(SNDRV_CTL_IOCTL_RAWMIDI_INFO),
+ MAP_COMPAT(SNDRV_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE),
{ 0 },
};
};
struct ioctl32_mapper seq_mappers[] = {
- { SNDRV_SEQ_IOCTL_PVERSION, NULL },
- { SNDRV_SEQ_IOCTL_CLIENT_ID, NULL },
- { SNDRV_SEQ_IOCTL_SYSTEM_INFO, NULL },
- { SNDRV_SEQ_IOCTL_GET_CLIENT_INFO, NULL },
- { SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, NULL },
+ MAP_COMPAT(SNDRV_SEQ_IOCTL_PVERSION),
+ MAP_COMPAT(SNDRV_SEQ_IOCTL_CLIENT_ID),
+ MAP_COMPAT(SNDRV_SEQ_IOCTL_SYSTEM_INFO),
+ MAP_COMPAT(SNDRV_SEQ_IOCTL_GET_CLIENT_INFO),
+ MAP_COMPAT(SNDRV_SEQ_IOCTL_SET_CLIENT_INFO),
{ SNDRV_SEQ_IOCTL_CREATE_PORT32, AP(create_port) },
{ SNDRV_SEQ_IOCTL_DELETE_PORT32, AP(delete_port) },
{ SNDRV_SEQ_IOCTL_GET_PORT_INFO32, AP(get_port_info) },
{ SNDRV_SEQ_IOCTL_SET_PORT_INFO32, AP(set_port_info) },
- { SNDRV_SEQ_IOCTL_SUBSCRIBE_PORT, NULL },
- { SNDRV_SEQ_IOCTL_UNSUBSCRIBE_PORT, NULL },
- { SNDRV_SEQ_IOCTL_CREATE_QUEUE, NULL },
- { SNDRV_SEQ_IOCTL_DELETE_QUEUE, NULL },
- { SNDRV_SEQ_IOCTL_GET_QUEUE_INFO, NULL },
- { SNDRV_SEQ_IOCTL_SET_QUEUE_INFO, NULL },
- { SNDRV_SEQ_IOCTL_GET_NAMED_QUEUE, NULL },
- { SNDRV_SEQ_IOCTL_GET_QUEUE_STATUS, NULL },
- { SNDRV_SEQ_IOCTL_GET_QUEUE_TEMPO, NULL },
- { SNDRV_SEQ_IOCTL_SET_QUEUE_TEMPO, NULL },
- { SNDRV_SEQ_IOCTL_GET_QUEUE_TIMER, NULL },
- { SNDRV_SEQ_IOCTL_SET_QUEUE_TIMER, NULL },
- { SNDRV_SEQ_IOCTL_GET_QUEUE_CLIENT, NULL },
- { SNDRV_SEQ_IOCTL_SET_QUEUE_CLIENT, NULL },
- { SNDRV_SEQ_IOCTL_GET_CLIENT_POOL, NULL },
- { SNDRV_SEQ_IOCTL_SET_CLIENT_POOL, NULL },
- { SNDRV_SEQ_IOCTL_REMOVE_EVENTS, NULL },
- { SNDRV_SEQ_IOCTL_QUERY_SUBS, NULL },
- { SNDRV_SEQ_IOCTL_GET_SUBSCRIPTION, NULL },
- { SNDRV_SEQ_IOCTL_QUERY_NEXT_CLIENT, NULL },
+ MAP_COMPAT(SNDRV_SEQ_IOCTL_SUBSCRIBE_PORT),
+ MAP_COMPAT(SNDRV_SEQ_IOCTL_UNSUBSCRIBE_PORT),
+ MAP_COMPAT(SNDRV_SEQ_IOCTL_CREATE_QUEUE),
+ MAP_COMPAT(SNDRV_SEQ_IOCTL_DELETE_QUEUE),
+ MAP_COMPAT(SNDRV_SEQ_IOCTL_GET_QUEUE_INFO),
+ MAP_COMPAT(SNDRV_SEQ_IOCTL_SET_QUEUE_INFO),
+ MAP_COMPAT(SNDRV_SEQ_IOCTL_GET_NAMED_QUEUE),
+ MAP_COMPAT(SNDRV_SEQ_IOCTL_GET_QUEUE_STATUS),
+ MAP_COMPAT(SNDRV_SEQ_IOCTL_GET_QUEUE_TEMPO),
+ MAP_COMPAT(SNDRV_SEQ_IOCTL_SET_QUEUE_TEMPO),
+ MAP_COMPAT(SNDRV_SEQ_IOCTL_GET_QUEUE_TIMER),
+ MAP_COMPAT(SNDRV_SEQ_IOCTL_SET_QUEUE_TIMER),
+ MAP_COMPAT(SNDRV_SEQ_IOCTL_GET_QUEUE_CLIENT),
+ MAP_COMPAT(SNDRV_SEQ_IOCTL_SET_QUEUE_CLIENT),
+ MAP_COMPAT(SNDRV_SEQ_IOCTL_GET_CLIENT_POOL),
+ MAP_COMPAT(SNDRV_SEQ_IOCTL_SET_CLIENT_POOL),
+ MAP_COMPAT(SNDRV_SEQ_IOCTL_REMOVE_EVENTS),
+ MAP_COMPAT(SNDRV_SEQ_IOCTL_QUERY_SUBS),
+ MAP_COMPAT(SNDRV_SEQ_IOCTL_GET_SUBSCRIPTION),
+ MAP_COMPAT(SNDRV_SEQ_IOCTL_QUERY_NEXT_CLIENT),
{ SNDRV_SEQ_IOCTL_QUERY_NEXT_PORT32, AP(query_next_port) },
- { SNDRV_SEQ_IOCTL_RUNNING_MODE, NULL },
+ MAP_COMPAT(SNDRV_SEQ_IOCTL_RUNNING_MODE),
{ 0 },
};
};
struct ioctl32_mapper timer_mappers[] = {
- { SNDRV_TIMER_IOCTL_PVERSION, NULL },
- { SNDRV_TIMER_IOCTL_NEXT_DEVICE, NULL },
- { SNDRV_TIMER_IOCTL_SELECT, NULL },
+ MAP_COMPAT(SNDRV_TIMER_IOCTL_PVERSION),
+ MAP_COMPAT(SNDRV_TIMER_IOCTL_NEXT_DEVICE),
+ MAP_COMPAT(SNDRV_TIMER_IOCTL_SELECT),
{ SNDRV_TIMER_IOCTL_INFO32, AP(timer_info) },
- { SNDRV_TIMER_IOCTL_PARAMS, NULL },
+ MAP_COMPAT(SNDRV_TIMER_IOCTL_PARAMS),
{ SNDRV_TIMER_IOCTL_STATUS32, AP(timer_status) },
- { SNDRV_TIMER_IOCTL_START, NULL },
- { SNDRV_TIMER_IOCTL_STOP, NULL },
- { SNDRV_TIMER_IOCTL_CONTINUE, NULL },
+ MAP_COMPAT(SNDRV_TIMER_IOCTL_START),
+ MAP_COMPAT(SNDRV_TIMER_IOCTL_STOP),
+ MAP_COMPAT(SNDRV_TIMER_IOCTL_CONTINUE),
{ 0 },
};
}
/**
- * snd_dma_residue - return the residue count of the given DMA
+ * snd_dma_pointer - return the current pointer to DMA transfer buffer in bytes
* @dma: the dma number
+ * @size: the dma transfer size
*
- * Returns the residue count of the given DMA transfer.
+ * Returns the current pointer in DMA tranfer buffer in bytes
*/
-unsigned int snd_dma_residue(unsigned long dma)
+unsigned int snd_dma_pointer(unsigned long dma, unsigned int size)
{
unsigned long flags;
unsigned int result;
if (!isa_dma_bridge_buggy)
enable_dma(dma);
release_dma_lock(flags);
- return result;
+#ifdef CONFIG_SND_DEBUG
+ if (result > size)
+ snd_printk(KERN_ERR "pointer (0x%x) for DMA #%ld is greater than transfer size (0x%x)\n", result, dma, size);
+#endif
+ return result >= size ? 0 : result;
}
struct slot {
unsigned int signature;
unsigned int present;
- int channels;
+ unsigned int channels;
snd_kcontrol_t *kcontrol[SNDRV_MIXER_OSS_ITEM_COUNT];
unsigned int capture_item;
struct snd_mixer_oss_assign_table *assigned;
return 0;
}
-static int snd_mixer_oss_get_recsrc2(snd_mixer_oss_file_t *fmixer, int *active_index)
+static int snd_mixer_oss_get_recsrc2(snd_mixer_oss_file_t *fmixer, unsigned int *active_index)
{
snd_card_t *card = fmixer->card;
snd_mixer_oss_t *mixer = fmixer->mixer;
return err;
}
-static int snd_mixer_oss_put_recsrc2(snd_mixer_oss_file_t *fmixer, int active_index)
+static int snd_mixer_oss_put_recsrc2(snd_mixer_oss_file_t *fmixer, unsigned int active_index)
{
snd_card_t *card = fmixer->card;
snd_mixer_oss_t *mixer = fmixer->mixer;
struct slot *slot = NULL;
snd_ctl_elem_info_t *uinfo;
snd_ctl_elem_value_t *uctl;
- int err, idx;
+ int err;
+ unsigned int idx;
uinfo = snd_kcalloc(sizeof(*uinfo), GFP_KERNEL);
uctl = snd_kcalloc(sizeof(*uctl), GFP_KERNEL);
static struct snd_mixer_oss_assign_table fm_table = {
SOUND_MIXER_SYNTH, "FM", 0
};
- int idx;
+ unsigned int idx;
for (idx = 0; idx < sizeof(table) / sizeof(struct snd_mixer_oss_assign_table); idx++)
snd_mixer_oss_build_input(mixer, &table[idx], 0);
}
static int choose_rate(snd_pcm_substream_t *substream,
- snd_pcm_hw_params_t *params, int best_rate)
+ snd_pcm_hw_params_t *params, unsigned int best_rate)
{
snd_interval_t *it;
snd_pcm_hw_params_t *save;
- int rate;
+ unsigned int rate;
save = kmalloc(sizeof(*save), GFP_KERNEL);
if (save == NULL)
ret = snd_pcm_hw_param_set(substream, params,
SNDRV_PCM_HW_PARAM_RATE,
rate, 0);
- if (ret == rate) {
+ if (ret == (int)rate) {
kfree(save);
return rate;
}
tmp = runtime->oss.period_bytes - runtime->oss.buffer_used;
if (tmp > 0) {
if (copy_from_user(runtime->oss.buffer + runtime->oss.buffer_used, buf, tmp))
- return xfer > 0 ? xfer : -EFAULT;
+ return xfer > 0 ? (snd_pcm_sframes_t)xfer : -EFAULT;
}
runtime->oss.buffer_used += tmp;
buf += tmp;
if (runtime->oss.buffer_used == runtime->oss.period_bytes) {
tmp = snd_pcm_oss_write2(substream, runtime->oss.buffer, runtime->oss.period_bytes, 1);
if (tmp <= 0)
- return xfer > 0 ? xfer : tmp;
+ return xfer > 0 ? (snd_pcm_sframes_t)xfer : tmp;
runtime->oss.bytes += tmp;
runtime->oss.buffer_used = 0;
}
} else {
tmp = snd_pcm_oss_write2(substream, (char *)buf, runtime->oss.period_bytes, 0);
if (tmp <= 0)
- return xfer > 0 ? xfer : tmp;
+ return xfer > 0 ? (snd_pcm_sframes_t)xfer : tmp;
runtime->oss.bytes += tmp;
buf += tmp;
bytes -= tmp;
if (runtime->oss.buffer_used == 0) {
tmp = snd_pcm_oss_read2(substream, runtime->oss.buffer, runtime->oss.period_bytes, 1);
if (tmp <= 0)
- return xfer > 0 ? xfer : tmp;
+ return xfer > 0 ? (snd_pcm_sframes_t)xfer : tmp;
runtime->oss.bytes += tmp;
runtime->oss.buffer_used = runtime->oss.period_bytes;
}
if ((size_t) tmp > runtime->oss.buffer_used)
tmp = runtime->oss.buffer_used;
if (copy_to_user(buf, runtime->oss.buffer + (runtime->oss.period_bytes - runtime->oss.buffer_used), tmp))
- return xfer > 0 ? xfer : -EFAULT;
+ return xfer > 0 ? (snd_pcm_sframes_t)xfer : -EFAULT;
buf += tmp;
bytes -= tmp;
xfer += tmp;
} else {
tmp = snd_pcm_oss_read2(substream, (char *)buf, runtime->oss.period_bytes, 0);
if (tmp <= 0)
- return xfer > 0 ? xfer : tmp;
+ return xfer > 0 ? (snd_pcm_sframes_t)xfer : tmp;
runtime->oss.bytes += tmp;
buf += tmp;
bytes -= tmp;
return substream->runtime->oss.rate;
}
-static int snd_pcm_oss_set_channels(snd_pcm_oss_file_t *pcm_oss_file, int channels)
+static int snd_pcm_oss_set_channels(snd_pcm_oss_file_t *pcm_oss_file, unsigned int channels)
{
int idx;
if (channels < 1)
static int snd_pcm_oss_register_minor(snd_pcm_t * pcm)
{
pcm->oss.reg = 0;
- if (dsp_map[pcm->card->number] == pcm->device) {
+ if (dsp_map[pcm->card->number] == (int)pcm->device) {
char name[128];
int duplex;
register_oss_dsp(pcm, 0);
pcm->oss.reg++;
pcm->oss.reg_mask |= 1;
}
- if (adsp_map[pcm->card->number] == pcm->device) {
+ if (adsp_map[pcm->card->number] == (int)pcm->device) {
register_oss_dsp(pcm, 1);
pcm->oss.reg++;
pcm->oss.reg_mask |= 2;
{
snd_pcm_oss_disconnect_minor(pcm);
if (pcm->oss.reg) {
- if (dsp_map[pcm->card->number] == pcm->device) {
+ if (dsp_map[pcm->card->number] == (int)pcm->device) {
#ifdef SNDRV_OSS_INFO_DEV_AUDIO
snd_oss_info_unregister(SNDRV_OSS_INFO_DEV_AUDIO, pcm->card->number);
#endif
}
frames = err;
if (!plugin->prev) {
- if ((err = snd_pcm_plug_capture_disable_useless_channels(plug, dst_channels, dst_channels_final) < 0))
+ if ((err = snd_pcm_plug_capture_disable_useless_channels(plug, dst_channels, dst_channels_final)) < 0)
return err;
}
} else {
if (subdevice >= pstr->substream_count)
return -ENXIO;
for (substream = pstr->substream; substream; substream = substream->next)
- if (substream->number == subdevice)
+ if (substream->number == (int)subdevice)
break;
if (substream == NULL)
return -ENXIO;
delta = hw_ptr_interrupt - new_hw_ptr;
if (delta > 0) {
- if (delta < runtime->buffer_size / 2) {
+ if ((snd_pcm_uframes_t)delta < runtime->buffer_size / 2) {
snd_printd("Unexpected hw_pointer value (stream = %i, delta: -%ld, max jitter = %ld): wrong interrupt acknowledge?\n", substream->stream, (long) delta, runtime->buffer_size / 2);
return 0;
}
delta = old_hw_ptr - new_hw_ptr;
if (delta > 0) {
- if (delta < runtime->buffer_size / 2) {
+ if ((snd_pcm_uframes_t)delta < runtime->buffer_size / 2) {
snd_printd("Unexpected hw_pointer value (stream = %i, delta: -%ld, max jitter = %ld): wrong interrupt acknowledge?\n", substream->stream, (long) delta, runtime->buffer_size / 2);
return 0;
}
snd_pcm_hw_rule_t *rule)
{
unsigned int l = (unsigned long) rule->private;
- unsigned int width = l & 0xffff;
+ int width = l & 0xffff;
unsigned int msbits = l >> 16;
snd_interval_t *i = hw_param_interval(params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS);
if (snd_interval_single(i) && snd_interval_value(i) == width)
* snd_pcm_playback_data - check whether any data exists on the playback buffer
* @substream: the pcm substream instance
*
- * Checks whether any data exists on the playback buffer.
+ * Checks whether any data exists on the playback buffer. If stop_threshold
+ * is bigger or equal to boundary, then this function returns always non-zero.
*
* Returns non-zero if exists, or zero if not.
*/
int snd_pcm_playback_data(snd_pcm_substream_t *substream)
{
snd_pcm_runtime_t *runtime = substream->runtime;
+
+ if (runtime->stop_threshold >= runtime->boundary)
+ return 1;
return snd_pcm_playback_avail(runtime) < runtime->buffer_size;
}
runtime->silenced_size < runtime->buffer_size) {
snd_pcm_sframes_t noise_dist;
noise_dist = snd_pcm_playback_hw_avail(runtime) + runtime->silenced_size;
- snd_assert(noise_dist <= runtime->silence_threshold, );
+ snd_assert(noise_dist <= (snd_pcm_sframes_t)runtime->silence_threshold, );
frames = noise_dist - runtime->silence_threshold;
}
avail = snd_pcm_playback_avail(runtime);
}
if (avail < runtime->control->avail_min) {
snd_pcm_sframes_t n = runtime->control->avail_min - avail;
- if (n > 0 && frames > n)
+ if (n > 0 && frames > (snd_pcm_uframes_t)n)
frames = n;
}
if (avail < runtime->buffer_size) {
snd_pcm_sframes_t n = runtime->buffer_size - avail;
- if (n > 0 && frames > n)
+ if (n > 0 && frames > (snd_pcm_uframes_t)n)
frames = n;
}
if (frames == ULONG_MAX) {
size -= frames;
xfer += frames;
if (runtime->status->state == SNDRV_PCM_STATE_PREPARED &&
- snd_pcm_playback_hw_avail(runtime) >= runtime->start_threshold) {
+ snd_pcm_playback_hw_avail(runtime) >= (snd_pcm_sframes_t)runtime->start_threshold) {
err = snd_pcm_start(substream);
if (err < 0)
goto _end_unlock;
_end_unlock:
spin_unlock_irq(&runtime->lock);
_end:
- return xfer > 0 ? xfer : err;
+ return xfer > 0 ? (snd_pcm_sframes_t)xfer : err;
}
snd_pcm_sframes_t snd_pcm_lib_write(snd_pcm_substream_t *substream, const void *buf, snd_pcm_uframes_t size)
_end_unlock:
spin_unlock_irq(&runtime->lock);
_end:
- return xfer > 0 ? xfer : err;
+ return xfer > 0 ? (snd_pcm_sframes_t)xfer : err;
}
snd_pcm_sframes_t snd_pcm_lib_read(snd_pcm_substream_t *substream, void *buf, snd_pcm_uframes_t size)
MODULE_PARM_DESC(maximum_substreams, "Maximum substreams with preallocated DMA memory.");
MODULE_PARM_SYNTAX(maximum_substreams, SNDRV_BOOLEAN_TRUE_DESC);
-const static int snd_minimum_buffer = 16384;
+const static size_t snd_minimum_buffer = 16384;
/*
ret = 0;
goto __end;
}
- if (frames > hw_avail)
+ if (frames > (snd_pcm_uframes_t)hw_avail)
frames = hw_avail;
else
frames -= frames % runtime->xfer_align;
ret = 0;
goto __end;
}
- if (frames > hw_avail)
+ if (frames > (snd_pcm_uframes_t)hw_avail)
frames = hw_avail;
else
frames -= frames % runtime->xfer_align;
offset = area->vm_offset;
#endif
dma_bytes = PAGE_ALIGN(runtime->dma_bytes);
- if (size > dma_bytes)
+ if ((size_t)size > dma_bytes)
return -EINVAL;
if (offset > dma_bytes - size)
return -EINVAL;
struct snd_sg_buf *sgbuf = snd_magic_cast(snd_pcm_sgbuf_t, substream->dma_private, return NULL);
unsigned int idx = offset >> PAGE_SHIFT;
- if (idx >= sgbuf->pages)
+ if (idx >= (unsigned int)sgbuf->pages)
return NULL;
return sgbuf->page_table[idx];
}
err = -ENXIO;
goto __error;
}
- if (subdevice >= 0 && subdevice >= rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substream_count) {
+ if (subdevice >= 0 && (unsigned int)subdevice >= rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substream_count) {
err = -ENODEV;
goto __error;
}
err = -ENXIO;
goto __error;
}
- if (subdevice >= 0 && subdevice >= rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substream_count) {
+ if (subdevice >= 0 && (unsigned int)subdevice >= rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substream_count) {
err = -ENODEV;
goto __error;
}
return -ENXIO;
list_for_each(list, &pstr->substreams) {
substream = list_entry(list, snd_rawmidi_substream_t, list);
- if (substream->number == info->subdevice)
+ if ((unsigned int)substream->number == info->subdevice)
return snd_rawmidi_info(substream, info);
}
return -ENXIO;
count1 = runtime->buffer_size - runtime->hw_ptr;
if (count1 > count)
count1 = count;
- if (count1 > runtime->buffer_size - runtime->avail)
+ if (count1 > (int)(runtime->buffer_size - runtime->avail))
count1 = runtime->buffer_size - runtime->avail;
memcpy(runtime->buffer + runtime->hw_ptr, buffer, count1);
runtime->hw_ptr += count1;
if (count > 0) {
buffer += count1;
count1 = count;
- if (count1 > runtime->buffer_size - runtime->avail) {
+ if (count1 > (int)(runtime->buffer_size - runtime->avail)) {
count1 = runtime->buffer_size - runtime->avail;
runtime->xruns = count - count1;
}
if (count1 > count)
count1 = count;
spin_lock_irqsave(&runtime->lock, flags);
- if (count1 > runtime->avail)
+ if (count1 > (int)runtime->avail)
count1 = runtime->avail;
if (kernel) {
memcpy(buf + result, runtime->buffer + runtime->appl_ptr, count1);
count1 = runtime->buffer_size - runtime->hw_ptr;
if (count1 > count)
count1 = count;
- if (count1 > runtime->buffer_size - runtime->avail)
+ if (count1 > (int)(runtime->buffer_size - runtime->avail))
count1 = runtime->buffer_size - runtime->avail;
memcpy(buffer, runtime->buffer + runtime->hw_ptr, count1);
count -= count1;
result = 0;
spin_lock_irqsave(&runtime->lock, flags);
if (substream->append) {
- if (runtime->avail < count) {
+ if ((long)runtime->avail < count) {
spin_unlock_irqrestore(&runtime->lock, flags);
return -EAGAIN;
}
count1 = runtime->buffer_size - runtime->appl_ptr;
if (count1 > count)
count1 = count;
- if (count1 > runtime->avail)
+ if (count1 > (long)runtime->avail)
count1 = runtime->avail;
if (kernel) {
memcpy(runtime->buffer + runtime->appl_ptr, buf, count1);
continue;
result += count1;
buf += count1;
- if (count1 < count && (file->f_flags & O_NONBLOCK))
+ if ((size_t)count1 < count && (file->f_flags & O_NONBLOCK))
break;
count -= count1;
}
}
#ifdef CONFIG_SND_OSSEMUL
rmidi->ossreg = 0;
- if (rmidi->device == midi_map[rmidi->card->number]) {
+ if ((int)rmidi->device == midi_map[rmidi->card->number]) {
if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI,
rmidi->card, 0, &snd_rawmidi_reg, name) < 0) {
snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 0);
#endif
}
}
- if (rmidi->device == amidi_map[rmidi->card->number]) {
+ if ((int)rmidi->device == amidi_map[rmidi->card->number]) {
if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI,
rmidi->card, 1, &snd_rawmidi_reg, name) < 0) {
snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 1);
}
#ifdef CONFIG_SND_OSSEMUL
if (rmidi->ossreg) {
- if (rmidi->device == midi_map[rmidi->card->number]) {
+ if ((int)rmidi->device == midi_map[rmidi->card->number]) {
snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI, rmidi->card, 0);
#ifdef SNDRV_OSS_INFO_DEV_MIDI
snd_oss_info_unregister(SNDRV_OSS_INFO_DEV_MIDI, rmidi->card->number);
#endif
}
- if (rmidi->device == amidi_map[rmidi->card->number])
+ if ((int)rmidi->device == amidi_map[rmidi->card->number])
snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI, rmidi->card, 1);
rmidi->ossreg = 0;
}
#include <linux/mc146818rtc.h>
#endif
-/* use tasklet for interrupt handling */
-#define USE_TASKLET
-
#define RTC_FREQ 1024 /* default frequency */
#define NANO_SEC 1000000000L /* 10^9 in sec */
static atomic_t rtc_inc = ATOMIC_INIT(0);
static rtc_task_t rtc_task;
-/* tasklet */
-#ifdef USE_TASKLET
-static struct tasklet_struct rtc_tq;
-#endif
static int
rtctimer_open(snd_timer_t *t)
*/
static void rtctimer_interrupt(void *private_data)
{
- atomic_inc(&rtc_inc);
-#ifdef USE_TASKLET
- tasklet_hi_schedule(&rtc_tq);
-#else
- {
- int ticks = atomic_read(&rtc_inc);
- snd_timer_interrupt((snd_timer_t*)private_data, ticks);
- atomic_sub(ticks, &rtc_inc);
- }
-#endif /* USE_TASKLET */
-}
-
-#ifdef USE_TASKLET
-static void rtctimer_interrupt2(unsigned long private_data)
-{
- snd_timer_t *timer = (snd_timer_t *)private_data;
int ticks;
- snd_assert(timer != NULL, return);
- do {
- ticks = atomic_read(&rtc_inc);
- snd_timer_interrupt(timer, ticks);
- } while (!atomic_sub_and_test(ticks, &rtc_inc));
+ atomic_inc(&rtc_inc);
+ ticks = atomic_read(&rtc_inc);
+ snd_timer_interrupt((snd_timer_t*)private_data, ticks);
+ atomic_sub(ticks, &rtc_inc);
}
-#endif /* USE_TASKLET */
/*
if (err < 0)
return err;
-#ifdef USE_TASKLET
- tasklet_init(&rtc_tq, rtctimer_interrupt2, (unsigned long)timer);
-#endif /* USE_TASKLET */
-
strcpy(timer->name, "RTC timer");
timer->hw = rtc_hw;
timer->hw.resolution = NANO_SEC / rtctimer_freq;
# <empty string> - CONFIG_SND_SEQUENCER is undefined
# otherwise parameter #1 value
#
-sequencer := $(if $(subst y,,$(CONFIG_SND_SEQUENCER)),m,$(if $(CONFIG_SND_SEQUENCER),$(1)))
+sequencer = $(if $(subst y,,$(CONFIG_SND_SEQUENCER)),$(if $(1),m),$(if $(CONFIG_SND_SEQUENCER),$(1)))
obj-$(CONFIG_SND_SEQUENCER) += snd-seq.o snd-seq-device.o
ifeq ($(CONFIG_SND_SEQUENCER_OSS),y)
# <empty string> - CONFIG_SND_SEQUENCER is undefined
# otherwise parameter #1 value
#
-sequencer := $(if $(subst y,,$(CONFIG_SND_SEQUENCER)),m,$(if $(CONFIG_SND_SEQUENCER),$(1)))
+sequencer = $(if $(subst y,,$(CONFIG_SND_SEQUENCER)),$(if $(1),m),$(if $(CONFIG_SND_SEQUENCER),$(1)))
# Toplevel Module Dependency
obj-$(call sequencer,$(CONFIG_SND_ALS100)) += snd-ainstr-fm.o
if (cmd != SNDRV_SEQ_INSTR_PUT_CMD_CREATE)
return -EINVAL;
/* copy instrument data */
- if (len < sizeof(ix))
+ if (len < (long)sizeof(ix))
return -EINVAL;
if (copy_from_user(&ix, instr_data, sizeof(ix)))
return -EFAULT;
if (cmd != SNDRV_SEQ_INSTR_GET_CMD_FULL)
return -EINVAL;
- if (len < sizeof(ix))
+ if (len < (long)sizeof(ix))
return -ENOMEM;
memset(&ix, 0, sizeof(ix));
ip = (fm_instrument_t *)KINSTR_DATA(instr);
unsigned int real_size;
gfp_mask = atomic ? GFP_ATOMIC : GFP_KERNEL;
- if (*len < sizeof(xp))
+ if (*len < (long)sizeof(xp))
return -EINVAL;
if (copy_from_user(&xp, *data, sizeof(xp)))
return -EFAULT;
wp->scale_frequency = le16_to_cpu(xp.scale_frequency);
wp->scale_factor = le16_to_cpu(xp.scale_factor);
real_size = snd_seq_gf1_size(wp->size, wp->format);
- if (real_size > *len) {
+ if ((long)real_size > *len) {
kfree(wp);
return -ENOMEM;
}
return -EINVAL;
gfp_mask = atomic ? GFP_ATOMIC : GFP_KERNEL;
/* copy instrument data */
- if (len < sizeof(ix))
+ if (len < (long)sizeof(ix))
return -EINVAL;
if (copy_from_user(&ix, instr_data, sizeof(ix)))
return -EFAULT;
ip->effect2 = ix.effect2;
ip->effect2_depth = ix.effect2_depth;
/* copy layers */
- while (len > sizeof(__u32)) {
+ while (len > (long)sizeof(__u32)) {
__u32 stype;
if (copy_from_user(&stype, instr_data, sizeof(stype)))
unsigned int real_size;
for (wp = ip->wave; wp; wp = wp->next) {
- if (*len < sizeof(xp))
+ if (*len < (long)sizeof(xp))
return -ENOMEM;
memset(&xp, 0, sizeof(xp));
xp.stype = GF1_STRU_WAVE;
*data += sizeof(xp);
*len -= sizeof(xp);
real_size = snd_seq_gf1_size(wp->size, wp->format);
- if (*len < real_size)
+ if (*len < (long)real_size)
return -ENOMEM;
if (ops->get_sample) {
err = ops->get_sample(ops->private_data, wp,
if (cmd != SNDRV_SEQ_INSTR_GET_CMD_FULL)
return -EINVAL;
- if (len < sizeof(ix))
+ if (len < (long)sizeof(ix))
return -ENOMEM;
memset(&ix, 0, sizeof(ix));
ip = (gf1_instrument_t *)KINSTR_DATA(instr);
ep->index = ex->index;
rp_last = NULL;
while (1) {
- if (*len < sizeof(__u32))
+ if (*len < (long)sizeof(__u32))
return -EINVAL;
if (copy_from_user(&stype, data, sizeof(stype)))
return -EFAULT;
stype == IWFFFF_STRU_ENV_RECV)
return 0;
}
- if (*len < sizeof(rx))
+ if (*len < (long)sizeof(rx))
return -EINVAL;
if (copy_from_user(&rx, *data, sizeof(rx)))
return -EFAULT;
unsigned int real_size;
gfp_mask = atomic ? GFP_ATOMIC : GFP_KERNEL;
- if (*len < sizeof(xp))
+ if (*len < (long)sizeof(xp))
return -EINVAL;
if (copy_from_user(&xp, *data, sizeof(xp)))
return -EFAULT;
wp->high_note = xp.high_note;
real_size = snd_seq_iwffff_size(wp->size, wp->format);
if (!(wp->format & IWFFFF_WAVE_ROM)) {
- if (real_size > *len) {
+ if ((long)real_size > *len) {
kfree(wp);
return -ENOMEM;
}
return -EINVAL;
gfp_mask = atomic ? GFP_ATOMIC : GFP_KERNEL;
/* copy instrument data */
- if (len < sizeof(ix))
+ if (len < (long)sizeof(ix))
return -EINVAL;
if (copy_from_user(&ix, instr_data, sizeof(ix)))
return -EFAULT;
/* copy layers */
prev_lp = NULL;
while (len > 0) {
- if (len < sizeof(iwffff_xlayer_t)) {
+ if (len < (long)sizeof(iwffff_xlayer_t)) {
snd_seq_iwffff_instr_free(ops, ip, atomic);
return -EINVAL;
}
snd_seq_iwffff_instr_free(ops, ip, atomic);
return err;
}
- while (len > sizeof(__u32)) {
+ while (len > (long)sizeof(__u32)) {
__u32 stype;
if (copy_from_user(&stype, instr_data, sizeof(stype)))
ex->mode = ep->mode;
ex->index = ep->index;
for (rp = ep->record; rp; rp = rp->next) {
- if (*len < sizeof(rx))
+ if (*len < (long)sizeof(rx))
return -ENOMEM;
memset(&rx, 0, sizeof(rx));
rx.stype = req_stype;
unsigned int real_size;
for (wp = lp->wave; wp; wp = wp->next) {
- if (*len < sizeof(xp))
+ if (*len < (long)sizeof(xp))
return -ENOMEM;
memset(&xp, 0, sizeof(xp));
xp.stype = IWFFFF_STRU_WAVE;
*len -= sizeof(xp);
real_size = snd_seq_iwffff_size(wp->size, wp->format);
if (!(wp->format & IWFFFF_WAVE_ROM)) {
- if (*len < real_size)
+ if (*len < (long)real_size)
return -ENOMEM;
}
if (ops->get_sample) {
if (cmd != SNDRV_SEQ_INSTR_GET_CMD_FULL)
return -EINVAL;
- if (len < sizeof(ix))
+ if (len < (long)sizeof(ix))
return -ENOMEM;
memset(&ix, 0, sizeof(ix));
ip = (iwffff_instrument_t *)KINSTR_DATA(instr);
instr_data += sizeof(ix);
len -= sizeof(ix);
for (lp = ip->layer; lp; lp = lp->next) {
- if (len < sizeof(lx))
+ if (len < (long)sizeof(lx))
return -ENOMEM;
memset(&lx, 0, sizeof(lx));
lx.stype = IWFFFF_STRU_LAYER;
return -EINVAL;
gfp_mask = atomic ? GFP_ATOMIC : GFP_KERNEL;
/* copy instrument data */
- if (len < sizeof(ix))
+ if (len < (long)sizeof(ix))
return -EINVAL;
if (copy_from_user(&ix, instr_data, sizeof(ix)))
return -EFAULT;
ip->effect2 = ix.effect2;
ip->effect2_depth = ix.effect2_depth;
real_size = snd_seq_simple_size(ip->size, ip->format);
- if (len < real_size)
+ if (len < (long)real_size)
return -EINVAL;
if (ops->put_sample) {
err = ops->put_sample(ops->private_data, ip,
if (cmd != SNDRV_SEQ_INSTR_GET_CMD_FULL)
return -EINVAL;
- if (len < sizeof(ix))
+ if (len < (long)sizeof(ix))
return -ENOMEM;
memset(&ix, 0, sizeof(ix));
ip = (simple_instrument_t *)KINSTR_DATA(instr);
instr_data += sizeof(ix);
len -= sizeof(ix);
real_size = snd_seq_simple_size(ip->size, ip->format);
- if (len < real_size)
+ if (len < (long)real_size)
return -ENOMEM;
if (ops->get_sample) {
err = ops->get_sample(ops->private_data, ip,
if (snd_seq_ev_is_variable(&event)) {
int extlen = event.data.ext.len & ~SNDRV_SEQ_EXT_MASK;
- if (extlen + len > count) {
+ if ((size_t)(extlen + len) > count) {
/* back out, will get an error this time or next */
err = -EINVAL;
break;
*
*----------------------------------------------------------------
*
- * This device handler separates the card driver module from sequencer
+ * This device handler seperates the card driver module from sequencer
* stuff (sequencer core, synth drivers, etc), so that user can avoid
* to spend unnecessary resources e.g. if he needs only listening to
* MP3s.
static int instr_free_compare(snd_seq_kinstr_t *instr,
snd_seq_instr_header_t *ifree,
- int client)
+ unsigned int client)
{
switch (ifree->cmd) {
case SNDRV_SEQ_INSTR_FREE_CMD_ALL:
instr = list->hash[idx];
prev = flist = NULL;
while (instr) {
- while (instr && instr_free_compare(instr, ifree, client)) {
+ while (instr && instr_free_compare(instr, ifree, (unsigned int)client)) {
prev = instr;
instr = instr->next;
}
seq_midisynth_t *msynth, *ms;
snd_seq_port_info_t port;
snd_rawmidi_info_t info;
- int newclient = 0, p, ports;
+ int newclient = 0;
+ unsigned int p, ports;
snd_seq_client_callback_t callbacks;
snd_seq_port_callback_t pcallbacks;
snd_seq_client_info_t inf;
/*
- * Process an event in a driver independent way. This means dealing
+ * Process an event in a driver independant way. This means dealing
* with RPN, NRPN, SysEx etc that are defined for common midi applications
* such as GM, GS and XG.
* There modes that this module will run in are:
}
/*
- * Do all driver independent operations for this controler and pass
+ * Do all driver independant operations for this controler and pass
* events that need to take place immediately to the driver.
*/
static void
len--;
/* GM on */
- if (len >= sizeof(gm_on_macro) &&
+ if (len >= (int)sizeof(gm_on_macro) &&
memcmp(buf, gm_on_macro, sizeof(gm_on_macro)) == 0) {
if (chset->midi_mode != SNDRV_MIDI_MODE_GS &&
chset->midi_mode != SNDRV_MIDI_MODE_XG) {
}
/* XG on */
- else if (len >= sizeof(xg_on_macro) &&
+ else if (len >= (int)sizeof(xg_on_macro) &&
memcmp(buf, xg_on_macro, sizeof(xg_on_macro)) == 0) {
int i;
chset->midi_mode = SNDRV_MIDI_MODE_XG;
/*{SNDRV_SEQ_EVENT_REGPARAM, extra_decode_rpn},*/
};
-#define numberof(ary) (sizeof(ary)/sizeof(ary[0]))
-
/*
* new/delete record
*/
*/
long snd_midi_event_decode(snd_midi_event_t *dev, unsigned char *buf, long count, snd_seq_event_t *ev)
{
- int cmd, type;
+ unsigned int cmd, type;
if (ev->type == SNDRV_SEQ_EVENT_NONE)
return -ENOENT;
- for (type = 0; type < numberof(status_event); type++) {
+ for (type = 0; type < ARRAY_SIZE(status_event); type++) {
if (ev->type == status_event[type].event)
goto __found;
}
- for (type = 0; type < numberof(extra_event); type++) {
+ for (type = 0; type < ARRAY_SIZE(extra_event); type++) {
if (ev->type == extra_event[type].event)
return extra_event[type].decode(dev, buf, count, ev);
}
/* exported */
int snd_seq_event_port_attach(int client,
snd_seq_port_callback_t *pcbp,
- int cap,
- int type,
+ int cap, int type, int midi_channels,
char *portname)
{
snd_seq_port_info_t portinfo;
portinfo.capability = cap;
portinfo.type = type;
portinfo.kernel = pcbp;
+ portinfo.midi_channels = midi_channels;
/* Create it */
ret = snd_seq_kernel_client_ctl(client,
#include "seq_timer.h"
#include "seq_info.h"
-static void snd_seq_check_queue_in_tasklet(unsigned long private_data);
-
/* list of allocated queues */
static queue_t *queue_list[SNDRV_SEQ_MAX_QUEUES];
static spinlock_t queue_list_lock = SPIN_LOCK_UNLOCKED;
spin_lock_init(&q->check_lock);
init_MUTEX(&q->timer_mutex);
snd_use_lock_init(&q->use_lock);
- tasklet_init(&q->taskq, snd_seq_check_queue_in_tasklet, (unsigned long)q);
q->queue = -1;
q->tickq = snd_seq_prioq_new();
static void queue_delete(queue_t *q)
{
/* stop and release the timer */
- snd_seq_timer_stop(q->timer, 0);
+ snd_seq_timer_stop(q->timer);
snd_seq_timer_close(q);
/* wait until access free */
snd_use_lock_sync(&q->use_lock);
void snd_seq_check_queue(queue_t *q, int atomic, int hop)
{
unsigned long flags;
- int dequeue;
- int rc;
snd_seq_event_cell_t *cell;
if (q == NULL)
q->check_blocked = 1;
spin_unlock_irqrestore(&q->check_lock, flags);
- if (atomic)
- dequeue = SNDRV_SEQ_MAX_DEQUEUE;
- else
- dequeue = 0x7fffffff; /* XXX */
-
__again:
/* Process tick queue... */
-
- /* limit the number of elements dequeued per pass to save the machine from lockups */
- while (dequeue > 0) {
-
- cell = snd_seq_prioq_cell_peek(q->tickq);
- if (cell == NULL)
- break;
+ while ((cell = snd_seq_prioq_cell_peek(q->tickq)) != NULL) {
if (snd_seq_compare_tick_time(&q->timer->tick.cur_tick, &cell->event.time.tick)) {
cell = snd_seq_prioq_cell_out(q->tickq);
- if (cell != NULL) {
- rc = snd_seq_dispatch_event(cell, atomic, hop);
- if (rc > 0)
- dequeue -= rc;
- }
+ if (cell)
+ snd_seq_dispatch_event(cell, atomic, hop);
} else {
/* event remains in the queue */
break;
/* Process time queue... */
-
- /* limit the number of elements dequeued per pass to save the machine from lockups */
- while (dequeue > 0) {
- cell = snd_seq_prioq_cell_peek(q->timeq);
- if (cell == NULL)
- break;
+ while ((cell = snd_seq_prioq_cell_peek(q->timeq)) != NULL) {
if (snd_seq_compare_real_time(&q->timer->cur_time, &cell->event.time.time)) {
cell = snd_seq_prioq_cell_out(q->timeq);
- if (cell != NULL) {
- rc = snd_seq_dispatch_event(cell, atomic, hop);
- if (rc > 0)
- dequeue -= rc;
- }
-
+ if (cell)
+ snd_seq_dispatch_event(cell, atomic, hop);
} else {
/* event remains in the queue */
break;
/* free lock */
spin_lock_irqsave(&q->check_lock, flags);
- if (q->check_again && dequeue > 0) {
+ if (q->check_again) {
q->check_again = 0;
spin_unlock_irqrestore(&q->check_lock, flags);
goto __again;
}
q->check_blocked = 0;
- if (dequeue <= 0 && atomic)
- tasklet_hi_schedule(&q->taskq);
spin_unlock_irqrestore(&q->check_lock, flags);
}
-/* tasklet */
-static void snd_seq_check_queue_in_tasklet(unsigned long private_data)
-{
- queue_t *q = (queue_t *)private_data;
- snd_seq_check_queue(q, 0, 0);
-}
/* enqueue a event to singe queue */
int snd_seq_enqueue_event(snd_seq_event_cell_t *cell, int atomic, int hop)
spin_unlock_irqrestore(&q->owner_lock, flags);
if (q->owner == client) {
if (q->timer->running)
- snd_seq_timer_stop(q->timer, 0);
+ snd_seq_timer_stop(q->timer);
snd_seq_timer_reset(q->timer);
}
queuefree(q);
case SNDRV_SEQ_EVENT_START:
snd_seq_prioq_leave(q->tickq, ev->source.client, 1);
snd_seq_prioq_leave(q->timeq, ev->source.client, 1);
- if (! snd_seq_timer_start(q->timer, atomic))
+ if (! snd_seq_timer_start(q->timer))
queue_broadcast_event(q, ev, from_timer_port, atomic, hop);
break;
case SNDRV_SEQ_EVENT_CONTINUE:
- if (! snd_seq_timer_continue(q->timer, atomic))
+ if (! snd_seq_timer_continue(q->timer))
queue_broadcast_event(q, ev, from_timer_port, atomic, hop);
break;
case SNDRV_SEQ_EVENT_STOP:
- snd_seq_timer_stop(q->timer, atomic);
+ snd_seq_timer_stop(q->timer);
queue_broadcast_event(q, ev, from_timer_port, atomic, hop);
break;
struct semaphore timer_mutex;
snd_use_lock_t use_lock;
-
- struct tasklet_struct taskq;
};
t->running = 0;
/* reset time */
- snd_seq_timer_stop(t, 0);
+ snd_seq_timer_stop(t);
snd_seq_timer_reset(t);
kfree(t);
/* called by timer interrupt routine. the period time since previous invocation is passed */
static void snd_seq_timer_interrupt(snd_timer_instance_t *timeri,
unsigned long resolution,
- unsigned long ticks, void *data)
+ unsigned long ticks)
{
unsigned long flags;
- queue_t *q = (queue_t *)data;
+ queue_t *q = (queue_t *)timeri->callback_data;
seq_timer_t *tmr;
if (q == NULL)
if (tempo <= 0)
return -EINVAL;
spin_lock_irqsave(&tmr->lock, flags);
- if (tempo != tmr->tempo) {
+ if ((unsigned int)tempo != tmr->tempo) {
tmr->tempo = tempo;
snd_seq_timer_set_tick_resolution(&tmr->tick, tmr->tempo, tmr->ppq, 1);
}
return 0;
}
-int snd_seq_timer_stop(seq_timer_t * tmr, int in_callback)
+int snd_seq_timer_stop(seq_timer_t * tmr)
{
if (! tmr->timeri)
return -EINVAL;
if (!tmr->running)
return 0;
tmr->running = 0;
- if (in_callback)
- snd_timer_del(tmr->timeri);
- else
- snd_timer_stop(tmr->timeri);
+ snd_timer_stop(tmr->timeri);
return 0;
}
return 0;
}
-int snd_seq_timer_start(seq_timer_t * tmr, int in_callback)
+int snd_seq_timer_start(seq_timer_t * tmr)
{
if (! tmr->timeri)
return -EINVAL;
if (tmr->running)
- snd_seq_timer_stop(tmr, in_callback);
+ snd_seq_timer_stop(tmr);
snd_seq_timer_reset(tmr);
if (initialize_timer(tmr) < 0)
return -EINVAL;
return 0;
}
-int snd_seq_timer_continue(seq_timer_t * tmr, int in_callback)
+int snd_seq_timer_continue(seq_timer_t * tmr)
{
if (! tmr->timeri)
return -EINVAL;
int snd_seq_timer_midi_close(queue_t *q);
void snd_seq_timer_defaults(seq_timer_t *tmr);
void snd_seq_timer_reset(seq_timer_t *tmr);
-int snd_seq_timer_stop(seq_timer_t *tmr, int in_callback);
-int snd_seq_timer_start(seq_timer_t *tmr, int in_callback);
-int snd_seq_timer_continue(seq_timer_t *tmr, int in_callback);
+int snd_seq_timer_stop(seq_timer_t *tmr);
+int snd_seq_timer_start(seq_timer_t *tmr);
+int snd_seq_timer_continue(seq_timer_t *tmr);
int snd_seq_timer_set_tempo(seq_timer_t *tmr, int tempo);
int snd_seq_timer_set_ppq(seq_timer_t *tmr, int ppq);
int snd_seq_timer_set_position_tick(seq_timer_t *tmr, snd_seq_tick_time_t position);
#ifdef CONFIG_ISA
EXPORT_SYMBOL(snd_dma_program);
EXPORT_SYMBOL(snd_dma_disable);
-EXPORT_SYMBOL(snd_dma_residue);
+EXPORT_SYMBOL(snd_dma_pointer);
#endif
/* info.c */
#ifdef CONFIG_PROC_FS
snd_timer_read_t *queue;
spinlock_t qlock;
wait_queue_head_t qchange_sleep;
+ struct fasync_struct *fasync;
} snd_timer_user_t;
/* list of timers */
}
INIT_LIST_HEAD(&timeri->open_list);
INIT_LIST_HEAD(&timeri->active_list);
+ INIT_LIST_HEAD(&timeri->ack_list);
INIT_LIST_HEAD(&timeri->slave_list_head);
INIT_LIST_HEAD(&timeri->slave_active_head);
- timeri->in_use = (atomic_t)ATOMIC_INIT(0);
timeri->timer = timer;
if (timer && timer->card && !try_module_get(timer->card->module)) {
slave->slave_id == master->slave_id) {
list_del(&slave->open_list);
list_add_tail(&slave->open_list, &master->slave_list_head);
+ spin_lock_irq(&slave_active_lock);
slave->master = master;
+ slave->timer = master->timer;
+ spin_unlock_irq(&slave_active_lock);
return;
}
}
{
snd_timer_instance_t *slave;
struct list_head *p, *n;
- unsigned long flags;
/* check all pending slaves */
list_for_each_safe(p, n, &snd_timer_slave_list) {
slave->slave_id == master->slave_id) {
list_del(p);
list_add_tail(p, &master->slave_list_head);
- spin_lock_irqsave(&slave_active_lock, flags);
- /* protected here so that timer_start() doesn't start
- * this slave yet.
- */
+ spin_lock_irq(&slave_active_lock);
slave->master = master;
- spin_unlock_irqrestore(&slave_active_lock, flags);
+ slave->timer = master->timer;
+ if (slave->flags & SNDRV_TIMER_IFLG_RUNNING)
+ list_add_tail(&slave->active_list, &master->slave_active_head);
+ spin_unlock_irq(&slave_active_lock);
}
}
}
return timeri;
}
+static int _snd_timer_stop(snd_timer_instance_t * timeri, int keep_flag);
/*
* close a timer instance
int snd_timer_close(snd_timer_instance_t * timeri)
{
snd_timer_t *timer = NULL;
- unsigned long flags;
struct list_head *p, *n;
snd_timer_instance_t *slave;
/* remove slave links */
list_for_each_safe(p, n, &timeri->slave_list_head) {
slave = (snd_timer_instance_t *)list_entry(p, snd_timer_instance_t, open_list);
+ spin_lock_irq(&slave_active_lock);
+ _snd_timer_stop(slave, 1);
list_del(p);
list_add_tail(p, &snd_timer_slave_list);
- spin_lock_irqsave(&slave_active_lock, flags);
- slave->flags &= ~SNDRV_TIMER_IFLG_RUNNING;
- list_del_init(&slave->active_list);
slave->master = NULL;
- spin_unlock_irqrestore(&slave_active_lock, flags);
+ slave->timer = NULL;
+ spin_unlock_irq(&slave_active_lock);
}
up(®ister_mutex);
}
return 1; /* delayed start */
}
+/*
+ * start the timer instance
+ */
int snd_timer_start(snd_timer_instance_t * timeri, unsigned int ticks)
{
snd_timer_t *timer;
return -EINVAL;
spin_lock_irqsave(&timer->lock, flags);
timeri->ticks = timeri->cticks = ticks;
+ timeri->pticks = 0;
result = snd_timer_start1(timer, timeri, ticks);
spin_unlock_irqrestore(&timer->lock, flags);
return result;
}
-/*
- * stop the timer instance.
- *
- * do not call this from the timer callback!
- */
-int snd_timer_stop(snd_timer_instance_t * timeri)
+static int _snd_timer_stop(snd_timer_instance_t * timeri, int keep_flag)
{
snd_timer_t *timer;
unsigned long flags;
snd_assert(timeri != NULL, return -ENXIO);
- if (timeri->flags & SNDRV_TIMER_IFLG_SLAVE) {
- spin_lock_irqsave(&slave_active_lock, flags);
- if (timeri->flags & SNDRV_TIMER_IFLG_RUNNING) {
- timeri->flags &= ~SNDRV_TIMER_IFLG_RUNNING;
- list_del_init(&timeri->active_list);
- }
- spin_unlock_irqrestore(&slave_active_lock, flags);
- return 0;
- }
timer = timeri->timer;
if (! timer)
return -EINVAL;
spin_lock_irqsave(&timer->lock, flags);
- while (atomic_read(&timeri->in_use)) {
+ list_del_init(&timeri->ack_list);
+ /* wait until the callback is finished */
+ while (timeri->flags & SNDRV_TIMER_IFLG_CALLBACK) {
spin_unlock_irqrestore(&timer->lock, flags);
udelay(10);
spin_lock_irqsave(&timer->lock, flags);
}
- if (timeri->flags & SNDRV_TIMER_IFLG_RUNNING) {
- timeri->flags &= ~SNDRV_TIMER_IFLG_RUNNING;
- list_del_init(&timeri->active_list);
- if (!(--timer->running)) {
- timer->hw.stop(timer);
- if (timer->flags & SNDRV_TIMER_FLG_RESCHED) {
- timer->flags &= ~SNDRV_TIMER_FLG_RESCHED;
- snd_timer_reschedule(timer, 0);
- if (timer->flags & SNDRV_TIMER_FLG_CHANGE) {
- timer->flags &= ~SNDRV_TIMER_FLG_CHANGE;
- timer->hw.start(timer);
- }
+ list_del_init(&timeri->active_list);
+ if ((timeri->flags & SNDRV_TIMER_IFLG_RUNNING) &&
+ !(timeri->flags & SNDRV_TIMER_IFLG_SLAVE) &&
+ !(--timer->running)) {
+ timer->hw.stop(timer);
+ if (timer->flags & SNDRV_TIMER_FLG_RESCHED) {
+ timer->flags &= ~SNDRV_TIMER_FLG_RESCHED;
+ snd_timer_reschedule(timer, 0);
+ if (timer->flags & SNDRV_TIMER_FLG_CHANGE) {
+ timer->flags &= ~SNDRV_TIMER_FLG_CHANGE;
+ timer->hw.start(timer);
}
}
- } else if (timeri->flags & SNDRV_TIMER_IFLG_START) {
- timeri->flags &= ~SNDRV_TIMER_IFLG_START;
- list_del_init(&timeri->active_list);
}
+ if (!keep_flag)
+ timeri->flags &= ~(SNDRV_TIMER_IFLG_RUNNING|SNDRV_TIMER_IFLG_START);
spin_unlock_irqrestore(&timer->lock, flags);
return 0;
}
/*
- * delete the timer instance from active list.
+ * stop the timer instance.
*
- * call this from the timer callback only!
+ * do not call this from the timer callback!
*/
-int snd_timer_del(snd_timer_instance_t * timeri)
+int snd_timer_stop(snd_timer_instance_t * timeri)
{
- snd_timer_t *timer;
-
- snd_assert(timeri != NULL, return -ENXIO);
-
- if (timeri->flags & SNDRV_TIMER_IFLG_SLAVE) {
- timeri->flags &= ~SNDRV_TIMER_IFLG_RUNNING;
- list_del_init(&timeri->active_list);
- return 0;
- }
-
- timer = timeri->timer;
- if (! timer)
- return -EINVAL;
- spin_lock(&timer->lock);
- if (timeri->flags & SNDRV_TIMER_IFLG_RUNNING) {
- timeri->flags &= ~SNDRV_TIMER_IFLG_RUNNING;
- list_del_init(&timeri->active_list);
- if (!(--timer->running))
- timer->hw.stop(timer);
- } else if (timeri->flags & SNDRV_TIMER_IFLG_START) {
- timeri->flags &= ~SNDRV_TIMER_IFLG_START;
- list_del_init(&timeri->active_list);
- }
- spin_unlock(&timer->lock);
- return 0;
+ return _snd_timer_stop(timeri, 0);
}
/*
spin_lock_irqsave(&timer->lock, flags);
if (!timeri->cticks)
timeri->cticks = 1;
+ timeri->pticks = 0;
result = snd_timer_start1(timer, timeri, timer->sticks);
spin_unlock_irqrestore(&timer->lock, flags);
return result;
timer->sticks = ticks;
}
+/*
+ * timer tasklet
+ *
+ */
+static void snd_timer_tasklet(unsigned long arg)
+{
+ snd_timer_t *timer = (snd_timer_t *) arg;
+ snd_timer_instance_t *ti;
+ struct list_head *p;
+ unsigned long resolution, ticks;
+
+ spin_lock(&timer->lock);
+ /* now process all callbacks */
+ while (!list_empty(&timer->sack_list_head)) {
+ p = timer->sack_list_head.next; /* get first item */
+ ti = (snd_timer_instance_t *)list_entry(p, snd_timer_instance_t, ack_list);
+
+ /* remove from ack_list and make empty */
+ list_del_init(p);
+
+ ticks = ti->pticks;
+ ti->pticks = 0;
+ resolution = ti->resolution;
+
+ ti->flags |= SNDRV_TIMER_IFLG_CALLBACK;
+ spin_unlock(&timer->lock);
+ if (ti->callback)
+ ti->callback(ti, resolution, ticks);
+ spin_lock(&timer->lock);
+ ti->flags &= ~SNDRV_TIMER_IFLG_CALLBACK;
+ }
+ spin_unlock(&timer->lock);
+}
/*
* timer interrupt
void snd_timer_interrupt(snd_timer_t * timer, unsigned long ticks_left)
{
snd_timer_instance_t *ti, *ts;
- unsigned long resolution;
- LIST_HEAD(done_list_head);
+ unsigned long resolution, ticks;
struct list_head *p, *q, *n;
+ int use_tasklet = 0;
if (timer == NULL)
return;
+
spin_lock(&timer->lock);
+
+ /* remember the current resolution */
+ if (timer->hw.c_resolution)
+ resolution = timer->hw.c_resolution(timer);
+ else
+ resolution = timer->hw.resolution;
+
/* loop for all active instances
* here we cannot use list_for_each because the active_list of a processed
* instance is relinked to done_list_head before callback is called.
*/
list_for_each_safe(p, n, &timer->active_list_head) {
ti = (snd_timer_instance_t *)list_entry(p, snd_timer_instance_t, active_list);
- if (ti->flags & SNDRV_TIMER_IFLG_RUNNING) {
- if (ti->cticks < ticks_left)
- ti->cticks = 0;
- else
- ti->cticks -= ticks_left;
- if (!ti->cticks) { /* expired */
- if (ti->flags & SNDRV_TIMER_IFLG_AUTO) {
- ti->cticks = ti->ticks;
+ if (!(ti->flags & SNDRV_TIMER_IFLG_RUNNING))
+ continue;
+ ti->pticks += ticks_left;
+ ti->resolution = resolution;
+ if (ti->cticks < ticks_left)
+ ti->cticks = 0;
+ else
+ ti->cticks -= ticks_left;
+ if (ti->cticks) /* not expired */
+ continue;
+ if (ti->flags & SNDRV_TIMER_IFLG_AUTO) {
+ ti->cticks = ti->ticks;
+ } else {
+ ti->flags &= ~SNDRV_TIMER_IFLG_RUNNING;
+ if (--timer->running)
+ list_del(p);
+ }
+ if (list_empty(&ti->ack_list)) {
+ if ((timer->hw.flags & SNDRV_TIMER_HW_TASKLET) ||
+ (ti->flags & SNDRV_TIMER_IFLG_FAST)) {
+ list_add_tail(&ti->ack_list, &timer->ack_list_head);
+ } else {
+ list_add_tail(&ti->ack_list, &timer->sack_list_head);
+ }
+ }
+ list_for_each(q, &ti->slave_active_head) {
+ ts = (snd_timer_instance_t *)list_entry(q, snd_timer_instance_t, active_list);
+ ts->pticks = ti->pticks;
+ ts->resolution = resolution;
+ if (list_empty(&ts->ack_list)) {
+ if ((timer->hw.flags & SNDRV_TIMER_HW_TASKLET) ||
+ (ti->flags & SNDRV_TIMER_IFLG_FAST)) {
+ list_add_tail(&ts->ack_list, &timer->ack_list_head);
} else {
- ti->flags &= ~SNDRV_TIMER_IFLG_RUNNING;
- timer->running--;
+ list_add_tail(&ts->ack_list, &timer->sack_list_head);
}
- /* relink to done_list */
- list_del(p);
- list_add_tail(p, &done_list_head);
- atomic_inc(&ti->in_use);
}
}
}
timer->hw.stop(timer);
}
- /* remember the current resolution */
- if (timer->hw.c_resolution)
- resolution = timer->hw.c_resolution(timer);
- else
- resolution = timer->hw.resolution;
+ /* now process all fast callbacks */
+ while (!list_empty(&timer->ack_list_head)) {
+ p = timer->ack_list_head.next; /* get first item */
+ ti = (snd_timer_instance_t *)list_entry(p, snd_timer_instance_t, ack_list);
+
+ /* remove from ack_list and make empty */
+ list_del_init(p);
+
+ ticks = ti->pticks;
+ ti->pticks = 0;
- /* now process all callbacks */
- list_for_each_safe(p, n, &done_list_head) {
- ti = (snd_timer_instance_t *)list_entry(p, snd_timer_instance_t, active_list);
- /* append to active_list */
- list_del(p);
- if (ti->flags & SNDRV_TIMER_IFLG_RUNNING)
- list_add_tail(p, &timer->active_list_head);
+ ti->flags |= SNDRV_TIMER_IFLG_CALLBACK;
spin_unlock(&timer->lock);
if (ti->callback)
- ti->callback(ti, resolution, ti->ticks, ti->callback_data);
- spin_lock(&slave_active_lock);
- /* call callbacks of slaves */
- list_for_each(q, &ti->slave_active_head) {
- ts = (snd_timer_instance_t *)list_entry(q, snd_timer_instance_t, active_list);
- if (ts->callback)
- ts->callback(ts, resolution, ti->ticks, ts->callback_data);
- }
- spin_unlock(&slave_active_lock);
+ ti->callback(ti, resolution, ticks);
spin_lock(&timer->lock);
- atomic_dec(&ti->in_use);
+ ti->flags &= ~SNDRV_TIMER_IFLG_CALLBACK;
}
+
+ /* do we have any slow callbacks? */
+ use_tasklet = !list_empty(&timer->sack_list_head);
spin_unlock(&timer->lock);
-}
+ if (use_tasklet)
+ tasklet_hi_schedule(&timer->task_queue);
+}
/*
INIT_LIST_HEAD(&timer->device_list);
INIT_LIST_HEAD(&timer->open_list_head);
INIT_LIST_HEAD(&timer->active_list_head);
+ INIT_LIST_HEAD(&timer->ack_list_head);
+ INIT_LIST_HEAD(&timer->sack_list_head);
spin_lock_init(&timer->lock);
+ tasklet_init(&timer->task_queue, snd_timer_tasklet, (unsigned long)timer);
if (card != NULL) {
if ((err = snd_device_new(card, SNDRV_DEV_TIMER, timer, &ops)) < 0) {
snd_timer_free(timer);
static struct _snd_timer_hardware snd_timer_system =
{
- .flags = SNDRV_TIMER_HW_FIRST,
+ .flags = SNDRV_TIMER_HW_FIRST | SNDRV_TIMER_HW_TASKLET,
.resolution = 1000000000L / HZ,
.ticks = 10000000L,
.start = snd_timer_s_start,
static void snd_timer_user_interrupt(snd_timer_instance_t *timeri,
unsigned long resolution,
- unsigned long ticks,
- void *data)
+ unsigned long ticks)
{
- unsigned long flags;
- snd_timer_user_t *tu = snd_magic_cast(snd_timer_user_t, data, return);
+ snd_timer_user_t *tu = snd_magic_cast(snd_timer_user_t, timeri->callback_data, return);
snd_timer_read_t *r;
+ int _wake = 0;
+ spin_lock(&tu->qlock);
if (tu->qused >= tu->queue_size) {
tu->overrun++;
} else {
- spin_lock_irqsave(&tu->qlock, flags);
r = &tu->queue[tu->qtail++];
tu->qtail %= tu->queue_size;
r->resolution = resolution;
r->ticks = ticks;
tu->qused++;
- spin_unlock_irqrestore(&tu->qlock, flags);
+ _wake++;
+ }
+ spin_unlock(&tu->qlock);
+ if (_wake) {
+ kill_fasync(&tu->fasync, SIGIO, POLL_IN);
wake_up(&tu->qchange_sleep);
}
}
if (file->private_data) {
tu = snd_magic_cast(snd_timer_user_t, file->private_data, return -ENXIO);
file->private_data = NULL;
+ fasync_helper(-1, file, 0, &tu->fasync);
if (tu->timeri)
snd_timer_close(tu->timeri);
if (tu->queue)
tselect.id.dev_sclass = SNDRV_TIMER_SCLASS_APPLICATION;
if ((tu->timeri = snd_timer_open(str, &tselect.id, current->pid)) == NULL)
return -ENODEV;
+ tu->timeri->flags |= SNDRV_TIMER_IFLG_FAST;
tu->timeri->callback = snd_timer_user_interrupt;
tu->timeri->callback_data = (void *)tu;
return 0;
tu->timeri->flags &= ~SNDRV_TIMER_IFLG_AUTO;
}
spin_unlock_irqrestore(&t->lock, flags);
- if (params.queue_size > 0 && tu->queue_size != params.queue_size) {
+ if (params.queue_size > 0 && (unsigned int)tu->queue_size != params.queue_size) {
tr = (snd_timer_read_t *)kmalloc(params.queue_size * sizeof(snd_timer_read_t), GFP_KERNEL);
if (tr) {
kfree(tu->queue);
return -ENOTTY;
}
+static int snd_timer_user_fasync(int fd, struct file * file, int on)
+{
+ snd_timer_user_t *tu;
+ int err;
+
+ tu = snd_magic_cast(snd_timer_user_t, file->private_data, return -ENXIO);
+ err = fasync_helper(fd, file, on, &tu->fasync);
+ if (err < 0)
+ return err;
+ return 0;
+}
+
static ssize_t snd_timer_user_read(struct file *file, char *buffer, size_t count, loff_t *offset)
{
snd_timer_user_t *tu;
int err = 0;
tu = snd_magic_cast(snd_timer_user_t, file->private_data, return -ENXIO);
+ spin_lock_irq(&tu->qlock);
while (count - result >= sizeof(snd_timer_read_t)) {
- spin_lock_irq(&tu->qlock);
while (!tu->qused) {
wait_queue_t wait;
init_waitqueue_entry(&wait, current);
add_wait_queue(&tu->qchange_sleep, &wait);
- spin_unlock(&tu->qlock);
+ spin_unlock_irq(&tu->qlock);
schedule();
spin_lock_irq(&tu->qlock);
}
tu->qhead %= tu->queue_size;
- spin_lock_irq(&tu->qlock);
- tu->qused--;
- spin_unlock_irq(&tu->qlock);
+
result += sizeof(snd_timer_read_t);
buffer += sizeof(snd_timer_read_t);
+
+ spin_lock_irq(&tu->qlock);
+ tu->qused--;
}
return result > 0 ? result : err;
}
.release = snd_timer_user_release,
.poll = snd_timer_user_poll,
.ioctl = snd_timer_user_ioctl,
+ .fasync = snd_timer_user_fasync,
};
static snd_minor_t snd_timer_reg =
EXPORT_SYMBOL(snd_timer_resolution);
EXPORT_SYMBOL(snd_timer_start);
EXPORT_SYMBOL(snd_timer_stop);
-EXPORT_SYMBOL(snd_timer_del);
EXPORT_SYMBOL(snd_timer_continue);
EXPORT_SYMBOL(snd_timer_new);
EXPORT_SYMBOL(snd_timer_global_new);
int __init snd_card_dummy_new_mixer(snd_card_dummy_t * dummy)
{
snd_card_t *card = dummy->card;
- int idx, err;
+ unsigned int idx;
+ int err;
snd_assert(dummy != NULL, return -EINVAL);
spin_lock_init(&dummy->mixer_lock);
{
mtpav_port_t *portp;
- if (mcrd->inmidiport > mcrd->num_ports * 2 + MTPAV_PIDX_BROADCAST)
+ if ((int)mcrd->inmidiport > mcrd->num_ports * 2 + MTPAV_PIDX_BROADCAST)
return;
portp = &mcrd->ports[mcrd->inmidiport];
SNDRV_SEQ_PORT_TYPE_MIDI_GENERIC |
SNDRV_SEQ_PORT_TYPE_MIDI_GM |
SNDRV_SEQ_PORT_TYPE_SYNTH,
+ voices,
name);
if (opl3->oss_chset->port < 0) {
snd_midi_channel_free_set(opl3->oss_chset);
mm_segment_t fs;
- if (count < sizeof(sbi)) {
+ if (count < (int)sizeof(sbi)) {
snd_printk("FM Error: Patch record too short\n");
return -EINVAL;
}
SNDRV_SEQ_PORT_TYPE_MIDI_GENERIC |
SNDRV_SEQ_PORT_TYPE_MIDI_GM |
SNDRV_SEQ_PORT_TYPE_SYNTH,
+ 16,
name);
if (opl3->chset->port < 0) {
snd_midi_channel_free_set(opl3->chset);
{
cs8427_t *chip = snd_magic_cast(cs8427_t, cs8427->private_data, return -ENXIO);
snd_kcontrol_t *kctl;
- int idx, err;
+ unsigned int idx;
+ int err;
snd_assert(play_substream && cap_substream, return -EINVAL);
for (idx = 0; idx < CONTROLS; idx++) {
snd_i2c_device_t *device;
tea6330t_t *tea;
snd_kcontrol_new_t *knew;
- int idx, err = -ENOMEM;
+ unsigned int idx;
+ int err = -ENOMEM;
u8 default_treble, default_bass;
unsigned char bytes[7];
size_t ptr;
if (!(chip->mode & AD1816A_MODE_PLAYBACK))
return 0;
- ptr = chip->p_dma_size - snd_dma_residue(chip->dma1);
+ ptr = snd_dma_pointer(chip->dma1, chip->p_dma_size);
return bytes_to_frames(substream->runtime, ptr);
}
size_t ptr;
if (!(chip->mode & AD1816A_MODE_CAPTURE))
return 0;
- ptr = chip->c_dma_size - snd_dma_residue(chip->dma2);
+ ptr = snd_dma_pointer(chip->dma2, chip->c_dma_size);
return bytes_to_frames(substream->runtime, ptr);
}
int snd_ad1816a_mixer(ad1816a_t *chip)
{
snd_card_t *card;
- int err, idx;
+ unsigned int idx;
+ int err;
snd_assert(chip != NULL && chip->card != NULL, return -EINVAL);
if (!(chip->image[AD1848_IFACE_CTRL] & AD1848_PLAYBACK_ENABLE))
return 0;
- ptr = chip->dma_size - snd_dma_residue(chip->dma);
+ ptr = snd_dma_pointer(chip->dma, chip->dma_size);
return bytes_to_frames(substream->runtime, ptr);
}
if (!(chip->image[AD1848_IFACE_CTRL] & AD1848_CAPTURE_ENABLE))
return 0;
- ptr = chip->dma_size - snd_dma_residue(chip->dma);
+ ptr = snd_dma_pointer(chip->dma, chip->dma_size);
return bytes_to_frames(substream->runtime, ptr);
}
{
snd_card_t *card;
snd_pcm_t *pcm;
- int err, idx;
+ unsigned int idx;
+ int err;
snd_assert(chip != NULL && chip->pcm != NULL, return -EINVAL);
static int __init snd_cmi8330_mixer(snd_card_t *card, struct snd_cmi8330 *acard)
{
- int idx, err;
+ unsigned int idx;
+ int err;
strcpy(card->mixername, "CMI8330/C3D");
if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE))
return 0;
- ptr = chip->p_dma_size - snd_dma_residue(chip->dma1);
+ ptr = snd_dma_pointer(chip->dma1, chip->p_dma_size);
return bytes_to_frames(substream->runtime, ptr);
}
if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_RECORD_ENABLE))
return 0;
- ptr = chip->c_dma_size - snd_dma_residue(chip->dma2);
+ ptr = snd_dma_pointer(chip->dma2, chip->c_dma_size);
return bytes_to_frames(substream->runtime, ptr);
}
#endif /* LEGACY_SUPPORT */
int snd_cs4231_mixer(cs4231_t *chip)
{
snd_card_t *card;
- int err, idx;
+ unsigned int idx;
+ int err;
snd_assert(chip != NULL && chip->pcm != NULL, return -EINVAL);
sb_port[dev] = pdev->resource[2].start;
irq[dev] = pdev->irq_resource[0].start;
dma1[dev] = pdev->dma_resource[0].start;
- dma2[dev] = pdev->dma_resource[1].start == 4 ? -1 : pdev->dma_resource[1].start;
+ dma2[dev] = pdev->dma_resource[1].start == 4 ? -1 : (int)pdev->dma_resource[1].start;
snd_printdd("isapnp WSS: wss port=0x%lx, fm port=0x%lx, sb port=0x%lx\n",
port[dev], fm_port[dev], sb_port[dev]);
snd_printdd("isapnp WSS: irq=%i, dma1=%i, dma2=%i\n",
{
cs4231_t *chip;
unsigned char ver1, ver2;
- int err, reg;
+ unsigned int reg;
+ int err;
*rchip = NULL;
if (hardware == CS4231_HW_DETECT)
int snd_cs4236_mixer(cs4231_t *chip)
{
snd_card_t *card;
- int err, idx, count;
+ unsigned int idx, count;
+ int err;
snd_kcontrol_new_t *kcontrol;
snd_assert(chip != NULL && chip->card != NULL, return -EINVAL);
kcontrol = snd_cs4236_3d_controls_cs4238;
break;
default:
- count = -1;
+ count = 0;
kcontrol = NULL;
}
for (idx = 0; idx < count; idx++, kcontrol++) {
}
#if 0
printk("trigger: val = 0x%x, value = 0x%x\n", val, value);
- printk("trigger: residue = 0x%x\n", get_dma_residue(chip->dma8));
+ printk("trigger: pointer = 0x%x\n", snd_dma_pointer(chip->dma8, chip->dma_size));
#endif
snd_es1688_write(chip, 0xb8, (val & 0xf0) | value);
spin_unlock(&chip->reg_lock);
if (chip->trigger_value != 0x05)
return 0;
- ptr = chip->dma_size - snd_dma_residue(chip->dma8);
+ ptr = snd_dma_pointer(chip->dma8, chip->dma_size);
return bytes_to_frames(substream->runtime, ptr);
}
if (chip->trigger_value != 0x0f)
return 0;
- ptr = chip->dma_size - snd_dma_residue(chip->dma8);
+ ptr = snd_dma_pointer(chip->dma8, chip->dma_size);
return bytes_to_frames(substream->runtime, ptr);
}
int snd_es1688_mixer(es1688_t *chip)
{
snd_card_t *card;
- int err, idx;
+ unsigned int idx;
+ int err;
unsigned char reg, val;
snd_assert(chip != NULL && chip->card != NULL, return -EINVAL);
if (substream->number == 0 && (chip->caps & ES18XX_PCM2)) {
if (!(chip->active & DAC2))
return 0;
- pos = chip->dma2_size - snd_dma_residue(chip->dma2);
+ pos = snd_dma_pointer(chip->dma2, chip->dma2_size);
return pos >> chip->dma2_shift;
} else {
if (!(chip->active & DAC1))
return 0;
- pos = chip->dma1_size - snd_dma_residue(chip->dma1);
+ pos = snd_dma_pointer(chip->dma1, chip->dma1_size);
return pos >> chip->dma1_shift;
}
}
if (!(chip->active & ADC1))
return 0;
- pos = chip->dma1_size - snd_dma_residue(chip->dma1);
+ pos = snd_dma_pointer(chip->dma1, chip->dma1_size);
return pos >> chip->dma1_shift;
}
static int __init snd_es18xx_mixer(es18xx_t *chip)
{
snd_card_t *card;
- int err, idx;
+ int err;
+ unsigned int idx;
card = chip->card;
strcpy(card->mixername, chip->pcm->name);
- for (idx = 0; idx < sizeof(snd_es18xx_base_controls) /
- sizeof(snd_es18xx_base_controls[0]); idx++) {
+ for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_base_controls); idx++) {
snd_kcontrol_t *kctl;
kctl = snd_ctl_new1(&snd_es18xx_base_controls[idx], chip);
if (chip->caps & ES18XX_HWV) {
return err;
}
if (chip->caps & ES18XX_PCM2) {
- for (idx = 0; idx < sizeof(snd_es18xx_pcm2_controls) /
- sizeof(snd_es18xx_pcm2_controls[0]); idx++) {
+ for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_pcm2_controls); idx++) {
if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_es18xx_pcm2_controls[idx], chip))) < 0)
return err;
}
} else {
- for (idx = 0; idx < sizeof(snd_es18xx_pcm1_controls) /
- sizeof(snd_es18xx_pcm1_controls[0]); idx++) {
+ for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_pcm1_controls); idx++) {
if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_es18xx_pcm1_controls[idx], chip))) < 0)
return err;
}
return err;
}
if (chip->caps & ES18XX_RECMIX) {
- for (idx = 0; idx < sizeof(snd_es18xx_recmix_controls) /
- sizeof(snd_es18xx_recmix_controls[0]); idx++) {
+ for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_recmix_controls); idx++) {
if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_es18xx_recmix_controls[idx], chip))) < 0)
return err;
}
break;
}
if (chip->caps & ES18XX_SPATIALIZER) {
- for (idx = 0; idx < sizeof(snd_es18xx_spatializer_controls) /
- sizeof(snd_es18xx_spatializer_controls[0]); idx++) {
+ for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_spatializer_controls); idx++) {
if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_es18xx_spatializer_controls[idx], chip))) < 0)
return err;
}
}
if (chip->caps & ES18XX_HWV) {
- for (idx = 0; idx < sizeof(snd_es18xx_hw_volume_controls) /
- sizeof(snd_es18xx_hw_volume_controls[0]); idx++) {
+ for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_hw_volume_controls); idx++) {
snd_kcontrol_t *kctl;
kctl = snd_ctl_new1(&snd_es18xx_hw_volume_controls[idx], chip);
if (idx == 0)
# <empty string> - CONFIG_SND_SEQUENCER is undefined
# otherwise parameter #1 value
#
-sequencer := $(if $(subst y,,$(CONFIG_SND_SEQUENCER)),m,$(if $(CONFIG_SND_SEQUENCER),$(1)))
+sequencer = $(if $(subst y,,$(CONFIG_SND_SEQUENCER)),$(if $(1),m),$(if $(CONFIG_SND_SEQUENCER),$(1)))
# Toplevel Module Dependency
obj-$(CONFIG_SND_GUSCLASSIC) += snd-gusclassic.o snd-gus-lib.o
if (ptr1 >= ptr2)
continue;
size1 = ptr2 - ptr1;
- if (size <= size1) {
+ if ((int)size <= size1) {
block->ptr = ptr1;
block->size = size;
return 0;
if (share_id != NULL) {
nblock = snd_gf1_mem_share(alloc, share_id);
if (nblock != NULL) {
- if (size != nblock->size) {
+ if (size != (int)nblock->size) {
/* TODO: remove in the future */
snd_printk("snd_gf1_mem_alloc - share: sizes differ\n");
goto __std;
int snd_gf1_new_mixer(snd_gus_card_t * gus)
{
snd_card_t *card;
- int idx, err, max;
+ unsigned int idx, max;
+ int err;
snd_assert(gus != NULL, return -EINVAL);
card = gus->card;
snd_gus_card_t * gus;
snd_pcm_substream_t * substream;
spinlock_t lock;
- int voices;
+ unsigned int voices;
snd_gus_voice_t *pvoices[2];
unsigned int memory;
unsigned short flags;
gus_pcm_private_t * pcmp;
snd_pcm_runtime_t * runtime;
unsigned char voice_ctrl, ramp_ctrl;
- int idx;
+ unsigned int idx;
unsigned int end, step;
if (!pvoice->private_data) {
static snd_pcm_uframes_t snd_gf1_pcm_capture_pointer(snd_pcm_substream_t * substream)
{
snd_gus_card_t *gus = snd_pcm_substream_chip(substream);
- int pos = gus->c_period_size - snd_dma_residue(gus->gf1.dma2);
+ int pos = snd_dma_pointer(gus->gf1.dma2, gus->c_period_size);
pos = bytes_to_frames(substream->runtime, (gus->c_pos + pos) % gus->c_dma_size);
return pos;
}
{
snd_gus_card_t *gus = snd_kcontrol_chip(kcontrol);
unsigned long flags;
- int change, idx;
+ int change;
+ unsigned int idx;
unsigned short val1, val2, vol;
gus_pcm_private_t *pcmp;
snd_gus_voice_t *pvoice;
snd_gus_port_t * port = (snd_gus_port_t *)private_data;
snd_gus_card_t * gus = port->gus;
snd_gus_voice_t * voice;
- int idx;
+ unsigned int idx;
if (info->voices > 32)
return -EINVAL;
snd_seq_kinstr_t *instr,
int what)
{
- int idx;
+ unsigned int idx;
snd_gus_card_t *gus = snd_magic_cast(snd_gus_card_t, private_data, return);
snd_gus_voice_t *pvoice;
unsigned long flags;
SNDRV_SEQ_PORT_TYPE_MIDI_GS |
SNDRV_SEQ_PORT_TYPE_DIRECT_SAMPLE |
SNDRV_SEQ_PORT_TYPE_SYNTH,
+ 16,
name);
if (p->chset->port < 0) {
result = p->chset->port;
{
snd_card_t *card = chip->card;
snd_ctl_elem_id_t id1, id2;
- int idx, err;
+ unsigned int idx;
+ int err;
memset(&id1, 0, sizeof(id1));
memset(&id2, 0, sizeof(id2));
static unsigned char snd_opti93x_get_freq(unsigned int rate)
{
- int i;
+ unsigned int i;
for (i = 0; i < RATES; i++) {
if (rate == rates[i])
if (!(chip->image[OPTi93X_IFACE_CONF] & OPTi93X_PLAYBACK_ENABLE))
return 0;
- ptr = chip->p_dma_size - snd_dma_residue(chip->dma1);
+ ptr = snd_dma_pointer(chip->dma1, chip->p_dma_size);
return bytes_to_frames(substream->runtime, ptr);
}
if (!(chip->image[OPTi93X_IFACE_CONF] & OPTi93X_CAPTURE_ENABLE))
return 0;
- ptr = chip->c_dma_size - snd_dma_residue(chip->dma2);
+ ptr = snd_dma_pointer(chip->dma2, chip->c_dma_size);
return bytes_to_frames(substream->runtime, ptr);
}
{
snd_card_t *card;
snd_kcontrol_new_t knew;
- int err, idx;
+ int err;
+ unsigned int idx;
snd_assert(chip != NULL && chip->card != NULL, return -EINVAL);
# <empty string> - CONFIG_SND_SEQUENCER is undefined
# otherwise parameter #1 value
#
-sequencer := $(if $(subst y,,$(CONFIG_SND_SEQUENCER)),m,$(if $(CONFIG_SND_SEQUENCER),$(1)))
+sequencer = $(if $(subst y,,$(CONFIG_SND_SEQUENCER)),$(if $(1),m),$(if $(CONFIG_SND_SEQUENCER),$(1)))
# Toplevel Module Dependency
obj-$(CONFIG_SND_ALS100) += snd-sb16-dsp.o snd-sb-common.o
snd_printk(KERN_WARNING "illegal chorus mode %d for uploading\n", mode);
return -EINVAL;
}
- if (len < sizeof(rec) || copy_from_user(&rec, buf, sizeof(rec)))
+ if (len < (long)sizeof(rec) || copy_from_user(&rec, buf, sizeof(rec)))
return -EFAULT;
chorus_parm[mode] = rec;
chorus_defined[mode] = 1;
snd_printk(KERN_WARNING "illegal reverb mode %d for uploading\n", mode);
return -EINVAL;
}
- if (len < sizeof(rec) || copy_from_user(&rec, buf, sizeof(rec)))
+ if (len < (long)sizeof(rec) || copy_from_user(&rec, buf, sizeof(rec)))
return -EFAULT;
reverb_parm[mode] = rec;
reverb_defined[mode] = 1;
add_timer(&rec->timer);
/* update period */
- if (rec->period_pos >= rec->period_size) {
+ if (rec->period_pos >= (int)rec->period_size) {
rec->period_pos %= rec->period_size;
spin_unlock(&rec->timer_lock);
snd_pcm_period_elapsed(rec->substream);
if (csp->running & SNDRV_SB_CSP_ST_LOADED) {
/* manually loaded codec */
if ((csp->mode & SNDRV_SB_CSP_MODE_DSP_WRITE) &&
- ((1 << runtime->format) == csp->acc_format)) {
+ ((1U << runtime->format) == csp->acc_format)) {
/* Supported runtime PCM format for playback */
if (csp->ops.csp_use(csp) == 0) {
/* If CSP was successfully acquired */
if (csp->running & SNDRV_SB_CSP_ST_LOADED) {
/* manually loaded codec */
if ((csp->mode & SNDRV_SB_CSP_MODE_DSP_READ) &&
- ((1 << runtime->format) == csp->acc_format)) {
+ ((1U << runtime->format) == csp->acc_format)) {
/* Supported runtime PCM format for capture */
if (csp->ops.csp_use(csp) == 0) {
/* If CSP was successfully acquired */
size_t ptr;
dma = (chip->mode & SB_MODE_PLAYBACK_8) ? chip->dma8 : chip->dma16;
- ptr = chip->p_dma_size - snd_dma_residue(dma);
+ ptr = snd_dma_pointer(dma, chip->p_dma_size);
return bytes_to_frames(substream->runtime, ptr);
}
size_t ptr;
dma = (chip->mode & SB_MODE_CAPTURE_8) ? chip->dma8 : chip->dma16;
- ptr = chip->c_dma_size - snd_dma_residue(dma);
+ ptr = snd_dma_pointer(dma, chip->c_dma_size);
return bytes_to_frames(substream->runtime, ptr);
}
if (chip->mode != SB_MODE_PLAYBACK_8)
return 0;
- ptr = chip->p_dma_size - snd_dma_residue(chip->dma8);
+ ptr = snd_dma_pointer(chip->dma8, chip->p_dma_size);
return bytes_to_frames(substream->runtime, ptr);
}
if (chip->mode != SB_MODE_CAPTURE_8)
return 0;
- ptr = chip->c_dma_size - snd_dma_residue(chip->dma8);
+ ptr = snd_dma_pointer(chip->dma8, chip->c_dma_size);
return bytes_to_frames(substream->runtime, ptr);
}
{
snd_card_t *card = chip->card;
snd_ctl_elem_id_t id1, id2;
- int idx, err;
+ unsigned int idx;
+ int err;
memset(&id1, 0, sizeof(id1));
memset(&id2, 0, sizeof(id2));
} else if (r.data[2] == 1) {
pd = (unsigned short *) &r.data[3];
} else {
- if (r.data[2] > sizeof (page_data)) {
+ if (r.data[2] > (long)sizeof (page_data)) {
snd_printk ("cannot write "
"> 255 bytes to FX\n");
return -EIO;
u32 length;
u16 *data_end = 0;
unsigned int i;
- const int max_blksize = 4096/2;
+ const unsigned int max_blksize = 4096/2;
unsigned int written;
unsigned int blocksize;
int dma_ack;
if (header->size) {
dev->freemem = wavefront_freemem (dev);
- if (dev->freemem < header->size) {
+ if (dev->freemem < (int)header->size) {
snd_printk ("insufficient memory to "
"load %d byte sample.\n",
header->size);
{ 0x434d4900, 0xffffff00, "C-Media Electronics", NULL },
{ 0x43525900, 0xffffff00, "Cirrus Logic", NULL },
{ 0x43585400, 0xffffff00, "Conexant", NULL },
+{ 0x44543000, 0xffffff00, "Diamond Technology", NULL },
{ 0x454d4300, 0xffffff00, "eMicro", NULL },
{ 0x45838300, 0xffffff00, "ESS Technology", NULL },
{ 0x48525300, 0xffffff00, "Intersil", NULL },
{ 0x43525960, 0xfffffff8, "CS4291", NULL },
{ 0x43585421, 0xffffffff, "HSD11246", NULL }, // SmartMC II
{ 0x43585428, 0xfffffff8, "Cx20468", patch_conexant }, // SmartAMC fixme: the mask might be different
+{ 0x44543031, 0xfffffff0, "DT0398", NULL },
{ 0x454d4328, 0xffffffff, "28028", NULL }, // same as TR28028?
{ 0x45838308, 0xffffffff, "ESS1988", NULL },
{ 0x48525300, 0xffffff00, "HMP9701", NULL },
return change;
}
+static int snd_ac97_put_spsa(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+ ac97_t *ac97 = snd_kcontrol_chip(kcontrol);
+ int reg = kcontrol->private_value & 0xff;
+ int shift = (kcontrol->private_value >> 8) & 0xff;
+ int mask = (kcontrol->private_value >> 16) & 0xff;
+ // int invert = (kcontrol->private_value >> 24) & 0xff;
+ unsigned short value, old, new;
+
+ value = (ucontrol->value.integer.value[0] & mask);
+
+ mask <<= shift;
+ value <<= shift;
+ spin_lock(&ac97->reg_lock);
+ old = ac97->regs[reg];
+ new = (old & ~mask) | value;
+ spin_unlock(&ac97->reg_lock);
+
+ if (old != new) {
+ int change;
+ unsigned short extst = ac97->regs[AC97_EXTENDED_STATUS];
+ snd_ac97_update_bits(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, 0); /* turn off */
+ change = snd_ac97_update_bits(ac97, reg, mask, value);
+ if (extst & AC97_EA_SPDIF)
+ snd_ac97_update_bits(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, AC97_EA_SPDIF); /* turn on again */
+ return change;
+ }
+ return 0;
+}
+
static const snd_kcontrol_new_t snd_ac97_controls_spdif[5] = {
{
.access = SNDRV_CTL_ELEM_ACCESS_READ,
},
AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",PLAYBACK,SWITCH),AC97_EXTENDED_STATUS, 2, 1, 0),
- AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "AC97-SPSA",AC97_EXTENDED_STATUS, 4, 3, 0)
+ // AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "AC97-SPSA",AC97_EXTENDED_STATUS, 4, 3, 0)
+ {
+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "AC97-SPSA",
+ .info = snd_ac97_info_single,
+ .get = snd_ac97_get_single,
+ .put = snd_ac97_put_spsa,
+ .private_value = AC97_EXTENDED_STATUS | (4 << 8) | (3 << 16) | (0 << 24),
+ },
};
static const snd_kcontrol_new_t snd_ac97_cirrus_controls_spdif[2] = {
/* 8: reserved */
AC97_SINGLE("Line-In As Surround", AC97_ALC650_MULTICH, 9, 1, 0),
AC97_SINGLE("Mic As Center/LFE", AC97_ALC650_MULTICH, 10, 1, 0),
- AC97_SINGLE("IEC958 Capture Switch", AC97_ALC650_MULTICH, 11, 1, 0),
- AC97_SINGLE("Analog to IEC958 Output", AC97_ALC650_MULTICH, 12, 1, 0),
- AC97_SINGLE("IEC958 Input Monitor", AC97_ALC650_MULTICH, 13, 1, 0),
#if 0 /* always set in patch_alc650 */
AC97_SINGLE("IEC958 Input Clock Enable", AC97_ALC650_CLOCK, 0, 1, 0),
AC97_SINGLE("IEC958 Input Pin Enable", AC97_ALC650_CLOCK, 1, 1, 0),
#endif
};
+static const snd_kcontrol_new_t snd_ac97_spdif_controls_alc650[] = {
+ AC97_SINGLE("IEC958 Capture Switch", AC97_ALC650_MULTICH, 11, 1, 0),
+ AC97_SINGLE("Analog to IEC958 Output", AC97_ALC650_MULTICH, 12, 1, 0),
+ AC97_SINGLE("IEC958 Input Monitor", AC97_ALC650_MULTICH, 13, 1, 0),
+};
+
/* The following snd_ac97_ymf753_... items added by David Shust (dshust@shustring.com) */
/* It is possible to indicate to the Yamaha YMF753 the type of speakers being used. */
{
snd_kcontrol_t *kctl;
const snd_kcontrol_new_t *knew;
- int err, idx;
+ int err;
+ unsigned int idx;
unsigned char max;
/* build master controls */
for (idx = 0; idx < ARRAY_SIZE(snd_ac97_controls_alc650); idx++)
if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_alc650[idx], ac97))) < 0)
return err;
+ if (ac97->ext_id & AC97_EI_SPDIF) {
+ for (idx = 0; idx < ARRAY_SIZE(snd_ac97_spdif_controls_alc650); idx++)
+ if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_spdif_controls_alc650[idx], ac97))) < 0)
+ return err;
+ }
break;
case AC97_ID_VT1616:
if (snd_ac97_try_bit(ac97, 0x5a, 9))
}
+/* wait for a while until registers are accessible after RESET
+ * return 0 if ok, negative not ready
+ */
+static int ac97_reset_wait(ac97_t *ac97, int timeout, int with_modem)
+{
+ signed long end_time;
+ end_time = jiffies + timeout;
+ do {
+ unsigned short ext_mid;
+
+ /* use preliminary reads to settle the communication */
+ snd_ac97_read(ac97, AC97_RESET);
+ snd_ac97_read(ac97, AC97_VENDOR_ID1);
+ snd_ac97_read(ac97, AC97_VENDOR_ID2);
+ /* modem? */
+ if (with_modem) {
+ ext_mid = snd_ac97_read(ac97, AC97_EXTENDED_MID);
+ if (ext_mid != 0xffff && (ext_mid & 1) != 0)
+ return 0;
+ }
+ /* because the PCM or MASTER volume registers can be modified,
+ * the REC_GAIN register is used for tests
+ */
+ /* test if we can write to the record gain volume register */
+ snd_ac97_write_cache(ac97, AC97_REC_GAIN, 0x8a05);
+ if (snd_ac97_read(ac97, AC97_REC_GAIN) == 0x8a05)
+ return 0;
+ set_current_state(TASK_UNINTERRUPTIBLE);
+ schedule_timeout(HZ/100);
+ } while (time_after_eq(end_time, jiffies));
+ return -ENODEV;
+}
+
/**
* snd_ac97_mixer - create an AC97 codec component
* @card: the card instance
ac97->wait(ac97);
else {
udelay(50);
-
- /* it's necessary to wait awhile until registers are accessible after RESET */
- /* because the PCM or MASTER volume registers can be modified, */
- /* the REC_GAIN register is used for tests */
- end_time = jiffies + HZ;
- do {
- unsigned short ext_mid;
-
- /* use preliminary reads to settle the communication */
- snd_ac97_read(ac97, AC97_RESET);
- snd_ac97_read(ac97, AC97_VENDOR_ID1);
- snd_ac97_read(ac97, AC97_VENDOR_ID2);
- /* modem? */
- ext_mid = snd_ac97_read(ac97, AC97_EXTENDED_MID);
- if (ext_mid != 0xffff && (ext_mid & 1) != 0)
- goto __access_ok;
- /* test if we can write to the record gain volume register */
- snd_ac97_write_cache(ac97, AC97_REC_GAIN, 0x8a05);
- if ((err = snd_ac97_read(ac97, AC97_REC_GAIN)) == 0x8a05)
- goto __access_ok;
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(HZ/100);
- } while (time_after_eq(end_time, jiffies));
- snd_printk("AC'97 %d:%d does not respond - RESET [REC_GAIN = 0x%x]\n", ac97->num, ac97->addr, err);
- snd_ac97_free(ac97);
- return -ENXIO;
+ if (ac97_reset_wait(ac97, HZ/2, 0) < 0 &&
+ ac97_reset_wait(ac97, HZ/2, 1) < 0) {
+ snd_printk("AC'97 %d:%d does not respond - RESET [REC_GAIN = 0x%x]\n", ac97->num, ac97->addr, err);
+ snd_ac97_free(ac97);
+ return -ENXIO;
+ }
}
__access_ok:
ac97->id = snd_ac97_read(ac97, AC97_VENDOR_ID1) << 16;
{
unsigned short val;
- /* enable spdif in */
- snd_ac97_write_cache(ac97, AC97_ALC650_CLOCK,
- snd_ac97_read(ac97, AC97_ALC650_CLOCK) | 0x03);
+ /* check spdif */
+ val = snd_ac97_read(ac97, AC97_EXTENDED_STATUS);
+ if (val & AC97_EA_SPCV) {
+ /* enable spdif in */
+ snd_ac97_write_cache(ac97, AC97_ALC650_CLOCK,
+ snd_ac97_read(ac97, AC97_ALC650_CLOCK) | 0x03);
+ } else
+ ac97->ext_id &= ~AC97_EI_SPDIF; /* disable extended-id */
+
val = snd_ac97_read(ac97, AC97_ALC650_MULTICH);
val &= ~0xc000; /* slot: 3,4,7,8,6,9 */
- snd_ac97_write_cache(ac97, AC97_ALC650_MULTICH,
- val | 0x03);
+ snd_ac97_write_cache(ac97, AC97_ALC650_MULTICH, val | 0x03);
+
/* full DAC volume */
snd_ac97_write_cache(ac97, AC97_ALC650_SURR_DAC_VOL, 0x0808);
snd_ac97_write_cache(ac97, AC97_ALC650_LFE_DAC_VOL, 0x0808);
int snd_ak4531_mixer(snd_card_t * card, ak4531_t * _ak4531, ak4531_t ** rak4531)
{
- int idx, err;
+ unsigned int idx;
+ int err;
ak4531_t * ak4531;
static snd_device_ops_t ops = {
.dev_free = snd_ak4531_dev_free,
#endif
/*
- * Constants definition
+ * Constants defination
*/
#ifndef PCI_VENDOR_ID_ALI
udelay(5000);
}
- snd_printk(KERN_WARNING "ali5451: reset time out\n");
+ /* non-fatal if you have a non PM capable codec */
+ /* snd_printk(KERN_WARNING "ali5451: reset time out\n"); */
return 0;
}
static int __devinit snd_ali_mixer(ali_t * codec)
{
ac97_t ac97;
- int err, idx;
+ unsigned int idx;
+ int err;
memset(&ac97, 0, sizeof(ac97));
ac97.write = snd_ali_codec_write;
/* enable PCI device */
if ((err = pci_enable_device(pci)) < 0)
return err;
- /* check, if we can restrict PCI DMA transfers to 30 bits */
- if (!pci_dma_supported(pci, 0x3fffffff)) {
- snd_printk("architecture does not support 30bit PCI busmaster DMA\n");
+ /* check, if we can restrict PCI DMA transfers to 31 bits */
+ if (!pci_dma_supported(pci, 0x7fffffff)) {
+ snd_printk("architecture does not support 31bit PCI busmaster DMA\n");
return -ENXIO;
}
- pci_set_dma_mask(pci, 0x3fffffff);
+ pci_set_dma_mask(pci, 0x7fffffff);
if ((codec = snd_magic_kcalloc(ali_t, 0, GFP_KERNEL)) == NULL)
return -ENOMEM;
#define CM_OPEN_DAC 0x10
#define CM_OPEN_ADC 0x20
#define CM_OPEN_SPDIF 0x40
+#define CM_OPEN_MCHAN 0x80
#define CM_OPEN_PLAYBACK (CM_CH_PLAY | CM_OPEN_DAC)
#define CM_OPEN_PLAYBACK2 (CM_CH_CAPT | CM_OPEN_DAC)
+#define CM_OPEN_PLAYBACK_MULTI (CM_CH_PLAY | CM_OPEN_DAC | CM_OPEN_MCHAN)
#define CM_OPEN_CAPTURE (CM_CH_CAPT | CM_OPEN_ADC)
#define CM_OPEN_SPDIF_PLAYBACK (CM_CH_PLAY | CM_OPEN_DAC | CM_OPEN_SPDIF)
#define CM_OPEN_SPDIF_CAPTURE (CM_CH_CAPT | CM_OPEN_ADC | CM_OPEN_SPDIF)
// {"IEC958 Out To DAC", 1}, // no longer used
{"IEC958 Loop", 0},
};
-#define CM_SAVED_MIXERS (sizeof(cm_saved_mixer)/sizeof(cm_saved_mixer[0]))
+#define CM_SAVED_MIXERS ARRAY_SIZE(cm_saved_mixer)
struct snd_stru_cmipci {
snd_card_t *card;
* calculate frequency
*/
-static int rates[] = { 5512, 11025, 22050, 44100, 8000, 16000, 32000, 48000 };
-#define RATES (sizeof(rates) / sizeof(rates[0]))
+static unsigned int rates[] = { 5512, 11025, 22050, 44100, 8000, 16000, 32000, 48000 };
static unsigned int snd_cmipci_rate_freq(unsigned int rate)
{
- int i;
- for (i = 0; i < RATES; i++) {
+ unsigned int i;
+ for (i = 0; i < ARRAY_SIZE(rates); i++) {
if (rates[i] == rate)
return i;
}
return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
}
+static int snd_cmipci_playback2_hw_params(snd_pcm_substream_t * substream,
+ snd_pcm_hw_params_t * hw_params)
+{
+ cmipci_t *cm = snd_pcm_substream_chip(substream);
+ if (params_channels(hw_params) > 2) {
+ down(&cm->open_mutex);
+ if (cm->opened[CM_CH_PLAY]) {
+ up(&cm->open_mutex);
+ return -EBUSY;
+ }
+ /* reserve the channel A */
+ cm->opened[CM_CH_PLAY] = CM_OPEN_PLAYBACK_MULTI;
+ up(&cm->open_mutex);
+ }
+ return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
+}
+
static void snd_cmipci_ch_reset(cmipci_t *cm, int ch)
{
int reset = CM_RST_CH0 << (cm->channel[ch].ch);
rec->period_size = runtime->period_size << rec->shift;
rec->dma_size <<= rec->ac3_shift;
rec->period_size <<= rec->ac3_shift;
+ if (runtime->channels > 2) {
+ /* multi-channels */
+ rec->dma_size = (rec->dma_size * runtime->channels) / 2;
+ rec->period_size = (rec->period_size * runtime->channels) / 2;
+ }
spin_lock_irqsave(&cm->reg_lock, flags);
/* program sample counts */
reg = rec->ch ? CM_REG_CH1_FRAME2 : CM_REG_CH0_FRAME2;
snd_cmipci_write_w(cm, reg, rec->dma_size - 1);
- snd_cmipci_write_w(cm, reg + 2, rec->period_size); /* FIXME: or period_size-1 ?? */
+ snd_cmipci_write_w(cm, reg + 2, rec->period_size - 1);
/* set adc/dac flag */
val = rec->ch ? CM_CHADC1 : CM_CHADC0;
ptr = bytes_to_frames(substream->runtime, ptr);
#endif
ptr >>= rec->ac3_shift;
+ if (substream->runtime->channels > 2)
+ ptr = (ptr * 2) / substream->runtime->channels;
return ptr;
}
static void save_mixer_state(cmipci_t *cm)
{
if (! cm->mixer_insensitive) {
- int i;
+ unsigned int i;
for (i = 0; i < CM_SAVED_MIXERS; i++) {
snd_kcontrol_t *ctl = cm->mixer_res_ctl[i];
if (ctl) {
static void restore_mixer_state(cmipci_t *cm)
{
if (cm->mixer_insensitive) {
- int i;
+ unsigned int i;
cm->mixer_insensitive = 0; /* at first clear this;
otherwise the changes will be ignored */
for (i = 0; i < CM_SAVED_MIXERS; i++) {
down(&cm->open_mutex);
if (cm->opened[ch] == mode) {
- snd_cmipci_ch_reset(cm, ch);
- cm->channel[ch].running = 0;
- cm->channel[ch].substream = NULL;
+ if (cm->channel[ch].substream) {
+ snd_cmipci_ch_reset(cm, ch);
+ cm->channel[ch].running = 0;
+ cm->channel[ch].substream = NULL;
+ }
cm->opened[ch] = 0;
if (! cm->channel[ch].is_dac) {
/* enable dual DAC mode again */
if ((err = open_device_check(cm, CM_OPEN_PLAYBACK, substream)) < 0)
return err;
runtime->hw = snd_cmipci_playback;
- if (cm->can_multi_ch) {
- runtime->hw.channels_max = cm->max_channels;
- if (cm->max_channels == 4)
- snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, &hw_constraints_channels_4);
- else
- snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, &hw_constraints_channels_6);
- }
snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 0x10000);
return 0;
}
if ((err = open_device_check(cm, CM_OPEN_PLAYBACK2, substream)) < 0) /* use channel B */
return err;
runtime->hw = snd_cmipci_playback2;
- snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 0x10000);
+ down(&cm->open_mutex);
+ if (! cm->opened[CM_CH_PLAY]) {
+ if (cm->can_multi_ch) {
+ runtime->hw.channels_max = cm->max_channels;
+ if (cm->max_channels == 4)
+ snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, &hw_constraints_channels_4);
+ else
+ snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, &hw_constraints_channels_6);
+ }
+ snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 0x10000);
+ }
+ up(&cm->open_mutex);
return 0;
}
{
cmipci_t *cm = snd_pcm_substream_chip(substream);
close_device_check(cm, CM_OPEN_PLAYBACK2);
+ close_device_check(cm, CM_OPEN_PLAYBACK_MULTI);
return 0;
}
.open = snd_cmipci_playback2_open,
.close = snd_cmipci_playback2_close,
.ioctl = snd_pcm_lib_ioctl,
- .hw_params = snd_cmipci_hw_params,
+ .hw_params = snd_cmipci_playback2_hw_params,
.hw_free = snd_cmipci_hw_free,
.prepare = snd_cmipci_capture_prepare, /* channel B */
.trigger = snd_cmipci_capture_trigger, /* channel B */
snd_card_t *card;
snd_kcontrol_new_t *sw;
snd_kcontrol_t *kctl;
- int idx, err;
+ unsigned int idx;
+ int err;
snd_assert(cm != NULL && cm->card != NULL, return -EINVAL);
return err;
}
#ifdef USE_VAR48KRATE
- for (val = 0; val < RATES; val++)
+ for (val = 0; val < ARRAY_SIZE(rates); val++)
snd_cmipci_set_pll(cm, rates[val], val);
/*
{
snd_card_t *card = chip->card;
u32 ulCLK;
- int i;
+ unsigned int i;
if (card->power_state == SNDRV_CTL_POWER_D3hot)
return;
static void cs4281_resume(cs4281_t *chip)
{
snd_card_t *card = chip->card;
- int i;
+ unsigned int i;
u32 ulCLK;
if (card->power_state == SNDRV_CTL_POWER_D0)
size_t hw_to_end = buffer_size - cpcm->hw_data;
size_t sw_to_end = cpcm->sw_bufsize - cpcm->sw_data;
size_t bytes = buffer_size - cpcm->hw_ready;
- if (cpcm->sw_ready < bytes)
+ if (cpcm->sw_ready < (int)bytes)
bytes = cpcm->sw_ready;
if (hw_to_end < bytes)
bytes = hw_to_end;
runtime->dma_area + cpcm->sw_data,
bytes);
cpcm->hw_data += bytes;
- if (cpcm->hw_data == buffer_size)
+ if ((int)cpcm->hw_data == buffer_size)
cpcm->hw_data = 0;
cpcm->sw_data += bytes;
if (cpcm->sw_data == cpcm->sw_bufsize)
chip->capt.sw_ready -= frames << chip->capt.shift;
chip->capt.appl_ptr = runtime->control->appl_ptr + frames;
while (chip->capt.hw_ready > 0 &&
- chip->capt.sw_ready < chip->capt.sw_bufsize) {
+ chip->capt.sw_ready < (int)chip->capt.sw_bufsize) {
size_t hw_to_end = buffer_size - chip->capt.hw_data;
size_t sw_to_end = chip->capt.sw_bufsize - chip->capt.sw_data;
size_t bytes = chip->capt.sw_bufsize - chip->capt.sw_ready;
- if (chip->capt.hw_ready < bytes)
+ if (chip->capt.hw_ready < (int)bytes)
bytes = chip->capt.hw_ready;
if (hw_to_end < bytes)
bytes = hw_to_end;
chip->capt.hw_area + chip->capt.hw_data,
bytes);
chip->capt.hw_data += bytes;
- if (chip->capt.hw_data == buffer_size)
+ if ((int)chip->capt.hw_data == buffer_size)
chip->capt.hw_data = 0;
chip->capt.sw_data += bytes;
if (chip->capt.sw_data == chip->capt.sw_bufsize)
cpcm->pcm_channel->sample_rate = sample_rate;
} else
/* if sample rate is changed */
- if (cpcm->pcm_channel->sample_rate != sample_rate) {
+ if ((int)cpcm->pcm_channel->sample_rate != sample_rate) {
int unlinked = cpcm->pcm_channel->unlinked;
cs46xx_dsp_destroy_pcm_channel (chip,cpcm->pcm_channel);
/* checking diff from the EGPIO direction register
should be enough */
- return (val1 != snd_cs46xx_peekBA0(chip, BA0_EGPIODR));
+ return (val1 != (int)snd_cs46xx_peekBA0(chip, BA0_EGPIODR));
}
(1 << 13) | (1 << 12);
- change = ins->spdif_csuv_default != val;
+ change = (unsigned int)ins->spdif_csuv_default != val;
ins->spdif_csuv_default = val;
if ( !(ins->spdif_status_out & DSP_SPDIF_STATUS_PLAYBACK_OPEN) )
ac97_t ac97;
snd_ctl_elem_id_t id;
int err;
- int idx;
+ unsigned int idx;
/* detect primary codec */
chip->nr_ac97_codecs = 0;
_end:
- /* dosoundcard specific mixer setup */
- if (chip->mixer_init) {
- snd_printdd ("calling chip->mixer_init(chip);\n");
- chip->mixer_init(chip);
- }
-
#endif /* CONFIG_SND_CS46XX_NEW_DSP */
/* add cs4630 mixer controls */
- for (idx = 0; idx < sizeof(snd_cs46xx_controls) /
- sizeof(snd_cs46xx_controls[0]); idx++) {
+ for (idx = 0; idx < ARRAY_SIZE(snd_cs46xx_controls); idx++) {
snd_kcontrol_t *kctl;
kctl = snd_ctl_new1(&snd_cs46xx_controls[idx], chip);
if ((err = snd_ctl_add(card, kctl)) < 0)
strcpy(id.name, "External Amplifier Power Down");
chip->eapd_switch = snd_ctl_find_id(chip->card, &id);
+ /* turn on amplifier */
+ chip->amplifier_ctrl(chip, 1);
+
+#ifdef CONFIG_SND_CS46XX_NEW_DSP
+ /* do soundcard specific mixer setup */
+ if (chip->mixer_init) {
+ snd_printdd ("calling chip->mixer_init(chip);\n");
+ chip->mixer_init(chip);
+ }
+#endif
+
return 0;
}
snd_cs46xx_region_t *region = (snd_cs46xx_region_t *)entry->private_data;
size = count;
- if (file->f_pos + size > region->size)
+ if (file->f_pos + (size_t)size > region->size)
size = region->size - file->f_pos;
if (size > 0) {
char *tmp;
static void hercules_mixer_init (cs46xx_t *chip)
{
#ifdef CONFIG_SND_CS46XX_NEW_DSP
- int idx,err;
+ unsigned int idx;
+ int err;
snd_card_t *card = chip->card;
#endif
snd_printdd ("initializing Hercules mixer\n");
#ifdef CONFIG_SND_CS46XX_NEW_DSP
- for (idx = 0 ; idx < sizeof(snd_hercules_controls) /
- sizeof(snd_hercules_controls[0]) ; idx++) {
+ for (idx = 0 ; idx < ARRAY_SIZE(snd_hercules_controls); idx++) {
snd_kcontrol_t *kctl;
kctl = snd_ctl_new1(&snd_hercules_controls[idx], chip);
};
static struct cs_card_type __devinitdata cards[] = {
- {0x1489, 0x7001, "Genius Soundmaker 128 value", NULL, amp_none, NULL, NULL},
- {0x5053, 0x3357, "Voyetra", NULL, amp_voyetra, NULL, voyetra_mixer_init},
- {0x1071, 0x6003, "Mitac MI6020/21", NULL, amp_voyetra, NULL, NULL},
- {0x14AF, 0x0050, "Hercules Game Theatre XP", NULL, amp_hercules, NULL, hercules_mixer_init},
- {0x1681, 0x0050, "Hercules Game Theatre XP", NULL, amp_hercules, NULL, hercules_mixer_init},
- {0x1681, 0x0051, "Hercules Game Theatre XP", NULL, amp_hercules, NULL, hercules_mixer_init},
- {0x1681, 0x0052, "Hercules Game Theatre XP", NULL, amp_hercules, NULL, hercules_mixer_init},
- {0x1681, 0x0053, "Hercules Game Theatre XP", NULL, amp_hercules, NULL, hercules_mixer_init},
- {0x1681, 0x0054, "Hercules Game Theatre XP", NULL, amp_hercules, NULL, hercules_mixer_init},
+ {
+ .vendor = 0x1489,
+ .id = 0x7001,
+ .name = "Genius Soundmaker 128 value",
+ /* nothing special */
+ },
+ {
+ .vendor = 0x5053,
+ .id = 0x3357,
+ .name = "Voyetra",
+ .amp = amp_voyetra,
+ .mixer_init = voyetra_mixer_init
+ },
+ {
+ .vendor = 0x1071,
+ .id = 0x6003,
+ .name = "Mitac MI6020/21",
+ .amp = amp_voyetra
+ },
+ {
+ .vendor = 0x14AF,
+ .id = 0x0050,
+ .name = "Hercules Game Theatre XP",
+ .amp = amp_hercules,
+ .mixer_init = hercules_mixer_init
+ },
+ {
+ .vendor = 0x1681,
+ .id = 0x0050,
+ .name = "Hercules Game Theatre XP",
+ .amp = amp_hercules,
+ .mixer_init = hercules_mixer_init
+ },
+ {
+ .vendor = 0x1681,
+ .id = 0x0051,
+ .name = "Hercules Game Theatre XP",
+ .amp = amp_hercules,
+ .mixer_init = hercules_mixer_init
+ },
+ {
+ .vendor = 0x1681,
+ .id = 0x0052,
+ .name = "Hercules Game Theatre XP",
+ .amp = amp_hercules,
+ .mixer_init = hercules_mixer_init
+ },
+ {
+ .vendor = 0x1681,
+ .id = 0x0053,
+ .name = "Hercules Game Theatre XP",
+ .amp = amp_hercules,
+ .mixer_init = hercules_mixer_init
+ },
+ {
+ .vendor = 0x1681,
+ .id = 0x0054,
+ .name = "Hercules Game Theatre XP",
+ .amp = amp_hercules,
+ .mixer_init = hercules_mixer_init
+ },
/* Not sure if the 570 needs the clkrun hack */
- {PCI_VENDOR_ID_IBM, 0x0132, "Thinkpad 570", clkrun_init, NULL, clkrun_hack, NULL},
- {PCI_VENDOR_ID_IBM, 0x0153, "Thinkpad 600X/A20/T20", clkrun_init, NULL, clkrun_hack, NULL},
- {PCI_VENDOR_ID_IBM, 0x1010, "Thinkpad 600E (unsupported)", NULL, NULL, NULL, NULL},
- {0, 0, "Card without SSID set", NULL, NULL, NULL, NULL },
- {0, 0, NULL, NULL, NULL, NULL, NULL}
+ {
+ .vendor = PCI_VENDOR_ID_IBM,
+ .id = 0x0132,
+ .name = "Thinkpad 570",
+ .init = clkrun_init,
+ .active = clkrun_hack
+ },
+ {
+ .vendor = PCI_VENDOR_ID_IBM,
+ .id = 0x0153,
+ .name = "Thinkpad 600X/A20/T20",
+ .init = clkrun_init,
+ .active = clkrun_hack
+ },
+ {
+ .vendor = PCI_VENDOR_ID_IBM,
+ .id = 0x1010,
+ .name = "Thinkpad 600E (unsupported)"
+ },
+ {} /* terminator */
};
chip->irq = -1;
chip->ba0_addr = pci_resource_start(pci, 0);
chip->ba1_addr = pci_resource_start(pci, 1);
- if (chip->ba0_addr == 0 || chip->ba0_addr == ~0 ||
- chip->ba1_addr == 0 || chip->ba1_addr == ~0) {
+ if (chip->ba0_addr == 0 || chip->ba0_addr == (unsigned long)~0 ||
+ chip->ba1_addr == 0 || chip->ba1_addr == (unsigned long)~0) {
snd_cs46xx_free(chip);
snd_printk("wrong address(es) - ba0 = 0x%lx, ba1 = 0x%lx\n", chip->ba0_addr, chip->ba1_addr);
return -ENOMEM;
for (idx = 0; idx < 5; idx++) {
region = &chip->region.idx[idx];
if ((region->resource = request_mem_region(region->base, region->size, region->name)) == NULL) {
- snd_cs46xx_free(chip);
snd_printk("unable to request memory region 0x%lx-0x%lx\n", region->base, region->base + region->size - 1);
+ snd_cs46xx_free(chip);
return -EBUSY;
}
region->remap_addr = (unsigned long) ioremap_nocache(region->base, region->size);
if (region->remap_addr == 0) {
- snd_cs46xx_free(chip);
snd_printk("%s ioremap problem\n", region->name);
+ snd_cs46xx_free(chip);
return -ENOMEM;
}
}
if (request_irq(pci->irq, snd_cs46xx_interrupt, SA_INTERRUPT|SA_SHIRQ, "CS46XX", (void *) chip)) {
- snd_cs46xx_free(chip);
snd_printk("unable to grab IRQ %d\n", pci->irq);
+ snd_cs46xx_free(chip);
return -EBUSY;
}
chip->irq = pci->irq;
return err;
}
- /* turn on amplifier */
- chip->amplifier_ctrl(chip, 1);
-
chip->active_ctrl(chip, -1); /* disable CLKRUN */
*rchip = chip;
static int shadow_and_reallocate_code (cs46xx_t * chip,u32 * data,u32 size, u32 overlay_begin_address)
{
- int i = 0,j, nreallocated = 0;
+ unsigned int i = 0, j, nreallocated = 0;
u32 hival,loval,address;
u32 mop_operands,mop_type,wide_op;
dsp_spos_instance_t * ins = chip->dsp_spos_instance;
{
cs46xx_t *chip = snd_magic_cast(cs46xx_t, entry->private_data, return);
/*dsp_spos_instance_t * ins = chip->dsp_spos_instance; */
- int i,col = 0;
+ unsigned int i,col = 0;
unsigned long dst = chip->region.idx[1].remap_addr + DSP_PARAMETER_BYTE_OFFSET;
symbol_entry_t * symbol;
}
if (col == 0) {
- snd_iprintf(buffer, "%04X ",i / sizeof(u32));
+ snd_iprintf(buffer, "%04X ", i / (unsigned int)sizeof(u32));
}
snd_iprintf(buffer,"%08X ",readl(dst + i));
static void _dsp_clear_sample_buffer (cs46xx_t *chip, u32 sample_buffer_addr, int dword_count)
{
- u32 dst = chip->region.idx[2].remap_addr + sample_buffer_addr;
+ unsigned long dst = chip->region.idx[2].remap_addr + sample_buffer_addr;
int i;
for (i = 0; i < dword_count ; ++i ) {
emu10k1_t *emu = snd_kcontrol_chip(kcontrol);
snd_emu10k1_fx8010_ctl_t *ctl = (snd_emu10k1_fx8010_ctl_t *)kcontrol->private_value;
unsigned long flags;
- int i;
+ unsigned int i;
spin_lock_irqsave(&emu->reg_lock, flags);
for (i = 0; i < ctl->vcount; i++)
snd_emu10k1_fx8010_ctl_t *ctl = (snd_emu10k1_fx8010_ctl_t *)kcontrol->private_value;
unsigned long flags;
unsigned int nval, val;
- int i, j, change = 0;
+ unsigned int i, j;
+ int change = 0;
spin_lock_irqsave(&emu->reg_lock, flags);
for (i = 0; i < ctl->vcount; i++) {
{
emu10k1_t *emu = snd_pcm_substream_chip(substream);
snd_emu10k1_fx8010_pcm_t *pcm = &emu->fx8010.pcm[substream->number];
- int i;
+ unsigned int i;
for (i = 0; i < pcm->channels; i++)
snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + 0x80 + pcm->etram[i], 0, 0);
emu10k1_t *emu = snd_pcm_substream_chip(substream);
snd_pcm_runtime_t *runtime = substream->runtime;
snd_emu10k1_fx8010_pcm_t *pcm = &emu->fx8010.pcm[substream->number];
- int i;
+ unsigned int i;
// printk("prepare: etram_pages = 0x%p, dma_area = 0x%x, buffer_size = 0x%x (0x%x)\n", emu->fx8010.etram_pages, runtime->dma_area, runtime->buffer_size, runtime->buffer_size << 2);
pcm->sw_data = pcm->sw_io = pcm->sw_ready = 0;
static int snd_emu10k1_verify_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *icode)
{
- int i;
+ unsigned int i;
snd_ctl_elem_id_t *_id, id;
emu10k1_fx8010_control_gpr_t *_gctl, gctl;
static void snd_emu10k1_add_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *icode)
{
- int i, j;
+ unsigned int i, j;
emu10k1_fx8010_control_gpr_t *_gctl, gctl;
snd_emu10k1_fx8010_ctl_t *ctl, nctl;
snd_kcontrol_new_t knew;
static void snd_emu10k1_del_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *icode)
{
- int i;
+ unsigned int i;
snd_ctl_elem_id_t *_id, id;
snd_emu10k1_fx8010_ctl_t *ctl;
static int snd_emu10k1_list_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *icode)
{
- int i = 0, j;
+ unsigned int i = 0, j;
unsigned int total = 0;
emu10k1_fx8010_control_gpr_t *_gctl, gctl;
snd_emu10k1_fx8010_ctl_t *ctl;
static int snd_emu10k1_ipcm_poke(emu10k1_t *emu, emu10k1_fx8010_pcm_t *ipcm)
{
- int err = 0, i;
+ unsigned int i;
+ int err = 0;
snd_emu10k1_fx8010_pcm_t *pcm;
if (ipcm->substream >= EMU10K1_FX8010_PCM_COUNT)
static int snd_emu10k1_ipcm_peek(emu10k1_t *emu, emu10k1_fx8010_pcm_t *ipcm)
{
- int err = 0, i;
+ unsigned int i;
+ int err = 0;
snd_emu10k1_fx8010_pcm_t *pcm;
if (ipcm->substream >= EMU10K1_FX8010_PCM_COUNT)
{
snd_card_t *card = ensoniq->card;
ak4531_t ak4531;
- int err, idx;
+ unsigned int idx;
+ int err;
/* try reset AK4531 */
outw(ES_1370_CODEC_WRITE(AK4531_RESET, 0x02), ES_REG(ensoniq, 1370_CODEC));
static int snd_ensoniq_joy_enable(ensoniq_t *ensoniq)
{
- static int last_jiffies = 0;
+ static unsigned long last_jiffies = 0;
unsigned long flags;
if (!request_region(ensoniq->gameport.io, 8, "ens137x: gameport")) {
static int snd_es1938_free(es1938_t *chip)
{
+ /*if (chip->rmidi)
+ snd_es1938_mixer_bits(chip, ESSSB_IREG_MPU401CONTROL, 0x40, 0);*/
#if defined(CONFIG_GAMEPORT) || defined(CONFIG_GAMEPORT_MODULE)
if (chip->gameport.io)
gameport_unregister_port(&chip->gameport);
/* MPU401 */
if (status & 0x80) {
- /* ack */
- snd_es1938_mixer_bits(chip, ESSSB_IREG_MPU401CONTROL, 0x40, 0);
- printk("midi interrupt..\n");
+ // snd_es1938_mixer_bits(chip, ESSSB_IREG_MPU401CONTROL, 0x40, 0); /* ack? */
if (chip->rmidi)
snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data, regs);
}
{
snd_card_t *card;
es1938_t *chip;
- int err, idx;
+ unsigned int idx;
+ int err;
snd_assert(pcm != NULL && pcm->card != NULL, return -EINVAL);
strcpy(card->mixername, pcm->name);
- for (idx = 0; idx < sizeof(snd_es1938_controls) /
- sizeof(snd_es1938_controls[0]); idx++) {
+ for (idx = 0; idx < ARRAY_SIZE(snd_es1938_controls); idx++) {
snd_kcontrol_t *kctl;
kctl = snd_ctl_new1(&snd_es1938_controls[idx], chip);
switch (idx) {
if (snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401,
chip->mpu_port, 1, chip->irq, 0, &chip->rmidi) < 0) {
printk(KERN_ERR "es1938: unable to initialize MPU-401\n");
- }
+ } /*else
+ snd_es1938_mixer_bits(chip, ESSSB_IREG_MPU401CONTROL, 0x40, 0x40);*/
+
#if defined(CONFIG_GAMEPORT) || defined(CONFIG_GAMEPORT_MODULE)
chip->gameport.io = chip->game_port;
gameport_register_port(&chip->gameport);
* DMA memory management *
*************************/
-/* Because the Maestro can only take adresses relative to the PCM base adress
+/* Because the Maestro can only take addresses relative to the PCM base adress
register :( */
static int calc_available_memory_size(es1968_t *chip)
val = oval & ~0x04;
if (ucontrol->value.integer.value[0])
val |= 0x04;
- if (val != oval); {
+ if (val != oval) {
pci_write_config_word(chip->pci, ESM_LEGACY_AUDIO_CONTROL, val);
return 1;
}
static int dev;
snd_card_t *card;
es1968_t *chip;
- int i, err;
+ unsigned int i;
+ int err;
if (dev >= SNDRV_CARDS)
return -ENODEV;
struct resource *res_port;
unsigned int multichannel: 1, /* multichannel support */
secondary: 1; /* secondary codec */
- unsigned char secondary_addr; /* addres of the secondary codec */
+ unsigned char secondary_addr; /* address of the secondary codec */
unsigned short ply_ctrl; /* playback control */
unsigned short cap_ctrl; /* capture control */
* Sample rate routines
*/
-static unsigned short snd_fm801_rate_bits(int rate)
+static unsigned short snd_fm801_rate_bits(unsigned int rate)
{
unsigned int idx;
static int __devinit snd_fm801_mixer(fm801_t *chip)
{
ac97_t ac97;
- int err, i;
+ unsigned int i;
+ int err;
memset(&ac97, 0, sizeof(ac97));
ac97.write = snd_fm801_codec_write;
void snd_ice1712_ak4524_reset(ice1712_t *ice, int state)
{
- int chip;
+ unsigned int chip;
unsigned char reg;
ak4524_t *ak = &ice->ak4524;
int __devinit snd_ice1712_ak4524_build_controls(ice1712_t *ice)
{
- int err, idx;
+ unsigned int idx;
+ int err;
ak4524_t *ak = &ice->ak4524;
for (idx = 0; idx < ak->num_dacs; ++idx) {
{
/* we use pins 39 and 41 of the VT1616 for left and right read outputs */
snd_ac97_write_cache(ice->ac97, 0x5a, snd_ac97_read(ice->ac97, 0x5a) & ~0x8000);
+ return 0;
}
static int __devinit snd_ice1712_ews_add_controls(ice1712_t *ice)
{
- int err, idx;
+ unsigned int idx;
+ int err;
snd_kcontrol_t *kctl;
/* all terratec cards have spdif */
/* card specific controls */
switch (ice->eeprom.subvendor) {
case ICE1712_SUBDEVICE_EWX2496:
- for (idx = 0; idx < sizeof(snd_ice1712_ewx2496_controls)/sizeof(snd_ice1712_ewx2496_controls[0]); idx++) {
+ for (idx = 0; idx < ARRAY_SIZE(snd_ice1712_ewx2496_controls); idx++) {
err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ewx2496_controls[idx], ice));
if (err < 0)
return err;
return err;
break;
case ICE1712_SUBDEVICE_EWS88D:
- for (idx = 0; idx < sizeof(snd_ice1712_ews88d_controls)/sizeof(snd_ice1712_ews88d_controls[0]); idx++) {
+ for (idx = 0; idx < ARRAY_SIZE(snd_ice1712_ews88d_controls); idx++) {
err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ews88d_controls[idx], ice));
if (err < 0)
return err;
}
break;
case ICE1712_SUBDEVICE_DMX6FIRE:
- for (idx = 0; idx < sizeof(snd_ice1712_6fire_controls)/sizeof(snd_ice1712_6fire_controls[0]); idx++) {
+ for (idx = 0; idx < ARRAY_SIZE(snd_ice1712_6fire_controls); idx++) {
err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_6fire_controls[idx], ice));
if (err < 0)
return err;
#define PCI_DEVICE_ID_VT1724 0x1724
#endif
+enum {
+ TYPE_ICE1712, TYPE_VT1724
+};
+
static struct pci_device_id snd_ice1712_ids[] __devinitdata = {
- { PCI_VENDOR_ID_ICE, PCI_DEVICE_ID_ICE_1712, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* ICE1712 */
- { PCI_VENDOR_ID_ICE, PCI_DEVICE_ID_VT1724, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* VT1724 */
+ { PCI_VENDOR_ID_ICE, PCI_DEVICE_ID_ICE_1712, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_ICE1712 }, /* ICE1712 */
+ { PCI_VENDOR_ID_ICE, PCI_DEVICE_ID_VT1724, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_VT1724 }, /* VT1724 */
{ 0, }
};
}
static int __devinit snd_ice1712_create(snd_card_t * card,
- struct pci_dev *pci,
- int omni,
- ice1712_t ** r_ice1712)
+ struct pci_dev *pci,
+ int vt1724,
+ int omni,
+ ice1712_t ** r_ice1712)
{
ice1712_t *ice;
int err;
if ((err = pci_enable_device(pci)) < 0)
return err;
/* VT1724 does not have 28bit DMA transfer limit */
- if (pci->device==PCI_DEVICE_ID_ICE_1712) {
+ if (! vt1724) {
/* check, if we can restrict PCI DMA transfers to 28 bits */
if (!pci_dma_supported(pci, 0x0fffffff)) {
snd_printk("architecture does not support 28bit PCI busmaster DMA\n");
}
pci_set_dma_mask(pci, 0x0fffffff);
}
- else pci_set_dma_mask(pci, 0xffffffff);
+ else
+ pci_set_dma_mask(pci, 0xffffffff);
ice = snd_magic_kcalloc(ice1712_t, 0, GFP_KERNEL);
if (ice == NULL)
return -ENOMEM;
- if (pci->device==PCI_DEVICE_ID_VT1724)
- ice->vt1724=1;
+ ice->vt1724 = vt1724 ? 1 : 0;
ice->omni = omni ? 1 : 0;
spin_lock_init(&ice->reg_lock);
init_MUTEX(&ice->gpio_mutex);
snd_card_t *card;
ice1712_t *ice;
int pcm_dev = 0, err;
+ int chip_type;
struct snd_ice1712_card_info **tbl, *c;
if (dev >= SNDRV_CARDS)
if (card == NULL)
return -ENOMEM;
- if (pci->device==PCI_DEVICE_ID_ICE_1712) {
+ chip_type = pci_id->driver_data;
+ if (chip_type == TYPE_ICE1712) {
strcpy(card->driver, "ICE1712");
strcpy(card->shortname, "ICEnsemble ICE1712");
} else {
strcpy(card->shortname, "ICEnsemble ICE1724");
}
- if ((err = snd_ice1712_create(card, pci, omni[dev], &ice)) < 0) {
+ if ((err = snd_ice1712_create(card, pci, chip_type, omni[dev], &ice)) < 0) {
snd_card_free(card);
return err;
}
} ice1712_eeprom_t;
struct snd_ak4524 {
- int num_adcs; /* AK4524 or AK4528 ADCs */
- int num_dacs; /* AK4524 or AK4528 DACs */
+ unsigned int num_adcs; /* AK4524 or AK4528 ADCs */
+ unsigned int num_dacs; /* AK4524 or AK4528 DACs */
unsigned char images[4][16];
unsigned char ipga_gain[4][2];
/* */
unsigned int pro_volumes[20];
int omni: 1; /* Delta Omni I/O */
- int num_total_dacs; /* total DACs */
+ unsigned int num_total_dacs; /* total DACs */
unsigned char hoontech_boxbits[4];
unsigned int hoontech_config;
unsigned short hoontech_boxconfig[4];
intel8x0_t *chip = snd_magic_cast(intel8x0_t, dev_id, return);
ichdev_t *ichdev;
unsigned int status;
- int i;
+ unsigned int i;
spin_lock(&chip->reg_lock);
status = igetdword(chip, chip->int_sta_reg);
static int snd_intel8x0_chip_init(intel8x0_t *chip)
{
- int i, err;
+ unsigned int i;
+ int err;
if (chip->device_type != DEVICE_ALI)
err = snd_intel8x0_ich_chip_init(chip);
static int snd_intel8x0_free(intel8x0_t *chip)
{
- int i;
+ unsigned int i;
if (chip->irq < 0)
goto __hw_end;
intel8x0_t ** r_intel8x0)
{
intel8x0_t *chip;
- int err, i;
+ int err;
+ unsigned int i;
unsigned int int_sta_masks;
ichdev_t *ichdev;
static snd_device_ops_t ops = {
i = kcontrol->private_value;
- if (u->value.enumerated.item[0] != korg1212->sharedBufferPtr->volumeData[i]) {
+ if (u->value.enumerated.item[0] != (unsigned int)korg1212->sharedBufferPtr->volumeData[i]) {
korg1212->sharedBufferPtr->routeData[i] = u->value.enumerated.item[0];
change = 1;
}
if (i >= 8) {
- if (u->value.enumerated.item[1] != korg1212->sharedBufferPtr->volumeData[i+1]) {
+ if (u->value.enumerated.item[1] != (unsigned int)korg1212->sharedBufferPtr->volumeData[i+1]) {
korg1212->sharedBufferPtr->routeData[i+1] = u->value.enumerated.item[1];
change = 1;
}
{
struct pci_dev *pci = korg1212->pci;
int err;
- int i;
+ unsigned int i;
unsigned ioport_size, iomem_size, iomem2_size;
dma_addr_t phys_addr;
static void
snd_m3_playback_setup(m3_t *chip, m3_dma_t *s, snd_pcm_substream_t *subs)
{
- int i;
+ unsigned int i;
/*
* some per client initializers
/*
* set an armload of static initializers
*/
- for (i = 0 ; i < (sizeof(pv) / sizeof(pv[0])) ; i++)
+ for (i = 0; i < ARRAY_SIZE(pv); i++)
snd_m3_assp_write(chip, MEMTYPE_INTERNAL_DATA,
s->inst.data + pv[i].addr, pv[i].val);
}
static void
snd_m3_capture_setup(m3_t *chip, m3_dma_t *s, snd_pcm_substream_t *subs)
{
- int i;
+ unsigned int i;
/*
* some per client initializers
/*
* set an armload of static initializers
*/
- for (i = 0 ; i < (sizeof(rv) / sizeof(rv[0])) ; i++)
+ for (i = 0; i < ARRAY_SIZE(rv); i++)
snd_m3_assp_write(chip, MEMTYPE_INTERNAL_DATA,
s->inst.data + rv[i].addr, rv[i].val);
}
static void snd_m3_assp_init(m3_t *chip)
{
- int i;
+ unsigned int i;
/* zero kernel data */
for (i = 0; i < (REV_B_DATA_MEMORY_UNIT_LENGTH * NUM_UNITS_KERNEL_DATA) / 2; i++)
/* The actual rates supported by the card. */
-static int samplerates[8] = {
+static unsigned int samplerates[8] = {
8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000,
};
#define NUM_SAMPLERATES (sizeof(samplerates) / sizeof(samplerates[0]))
* return the index of the target rate
*/
static int
-snd_nm256_fixed_rate(int rate)
+snd_nm256_fixed_rate(unsigned int rate)
{
- int i;
+ unsigned int i;
for (i = 0; i < NUM_SAMPLERATES; i++) {
if (rate == samplerates[i])
return i;
if ((err = snd_nm256_pcm(chip, 0)) < 0)
goto __error;
- if ((err = snd_nm256_mixer(chip) < 0))
+ if ((err = snd_nm256_mixer(chip)) < 0)
goto __error;
// pci_set_master(pci); /* needed? */
if ((rme32->rcreg & RME32_RCR_KMODE) &&
(rate = snd_rme32_capture_getrate(rme32, &dummy)) > 0) {
/* AutoSync */
- if (params_rate(params) != rate) {
+ if ((int)params_rate(params) != rate) {
spin_unlock_irq(&rme32->lock);
return -EIO;
}
return err;
}
if ((rate = snd_rme32_capture_getrate(rme32, &isadat)) > 0) {
- if (params_rate(params) != rate) {
+ if ((int)params_rate(params) != rate) {
spin_unlock_irqrestore(&rme32->lock, flags);
return -EIO;
}
{
rme32_t *rme32 = _snd_kcontrol_chip(kcontrol);
unsigned long flags;
- int items = 3;
+ unsigned int items = 3;
spin_lock_irqsave(&rme32->lock, flags);
ucontrol->value.enumerated.item[0] = snd_rme32_getinputtype(rme32);
val = ucontrol->value.enumerated.item[0] % items;
spin_lock_irqsave(&rme32->lock, flags);
- change = val != snd_rme32_getinputtype(rme32);
+ change = val != (unsigned int)snd_rme32_getinputtype(rme32);
snd_rme32_setinputtype(rme32, val);
spin_unlock_irqrestore(&rme32->lock, flags);
return change;
val = ucontrol->value.enumerated.item[0] % 3;
spin_lock_irqsave(&rme32->lock, flags);
- change = val != snd_rme32_getclockmode(rme32);
+ change = val != (unsigned int)snd_rme32_getclockmode(rme32);
snd_rme32_setclockmode(rme32, val);
spin_unlock_irqrestore(&rme32->lock, flags);
return change;
snd_rme96_create_switches(snd_card_t *card,
rme96_t *rme96);
+static int
+snd_rme96_getinputtype(rme96_t *rme96);
+
static inline unsigned int
snd_rme96_playback_ptr(rme96_t *rme96)
{
int rate, dummy;
if (!(rme96->wcreg & RME96_WCR_MASTER) &&
+ snd_rme96_getinputtype(rme96) != RME96_INPUT_ANALOG &&
(rate = snd_rme96_capture_getrate(rme96, &dummy)) > 0)
{
/* slave clock */
return err;
spin_lock_irqsave(&rme96->lock, flags);
if (!(rme96->wcreg & RME96_WCR_MASTER) &&
+ snd_rme96_getinputtype(rme96) != RME96_INPUT_ANALOG &&
(rate = snd_rme96_capture_getrate(rme96, &dummy)) > 0)
{
/* slave clock */
- if (params_rate(params) != rate) {
+ if ((int)params_rate(params) != rate) {
spin_unlock_irqrestore(&rme96->lock, flags);
return -EIO;
}
spin_unlock_irqrestore(&rme96->lock, flags);
return err;
}
- }
- snd_rme96_setframelog(rme96, params_channels(params), 0);
- if (rme96->playback_periodsize != 0) {
- if (params_period_size(params) << rme96->capture_frlog !=
- rme96->playback_periodsize)
- {
- spin_unlock_irqrestore(&rme96->lock, flags);
- return -EBUSY;
- }
} else if ((rate = snd_rme96_capture_getrate(rme96, &isadat)) > 0) {
- if (params_rate(params) != rate) {
+ if ((int)params_rate(params) != rate) {
spin_unlock_irqrestore(&rme96->lock, flags);
return -EIO;
}
return -EIO;
}
}
+ snd_rme96_setframelog(rme96, params_channels(params), 0);
+ if (rme96->playback_periodsize != 0) {
+ if (params_period_size(params) << rme96->capture_frlog !=
+ rme96->playback_periodsize)
+ {
+ spin_unlock_irqrestore(&rme96->lock, flags);
+ return -EBUSY;
+ }
+ }
rme96->capture_periodsize =
params_period_size(params) << rme96->capture_frlog;
snd_rme96_set_period_properties(rme96, rme96->capture_periodsize);
runtime->hw = snd_rme96_playback_spdif_info;
if (!(rme96->wcreg & RME96_WCR_MASTER) &&
+ snd_rme96_getinputtype(rme96) != RME96_INPUT_ANALOG &&
(rate = snd_rme96_capture_getrate(rme96, &dummy)) > 0)
{
/* slave clock */
snd_pcm_set_sync(substream);
runtime->hw = snd_rme96_capture_spdif_info;
- if ((rate = snd_rme96_capture_getrate(rme96, &isadat)) > 0) {
+ if (snd_rme96_getinputtype(rme96) != RME96_INPUT_ANALOG &&
+ (rate = snd_rme96_capture_getrate(rme96, &isadat)) > 0)
+ {
if (isadat) {
return -EIO;
}
runtime->hw = snd_rme96_playback_adat_info;
if (!(rme96->wcreg & RME96_WCR_MASTER) &&
+ snd_rme96_getinputtype(rme96) != RME96_INPUT_ANALOG &&
(rate = snd_rme96_capture_getrate(rme96, &dummy)) > 0)
{
/* slave clock */
snd_pcm_set_sync(substream);
runtime->hw = snd_rme96_capture_adat_info;
+ if (snd_rme96_getinputtype(rme96) != RME96_INPUT_ANALOG) {
+ /* makes no sense to use analog input. Note that analog
+ expension cards AEB4/8-I are RME96_INPUT_INTERNAL */
+ return -EIO;
+ }
if ((rate = snd_rme96_capture_getrate(rme96, &isadat)) > 0) {
if (!isadat) {
return -EIO;
snd_iprintf(buffer, " clock mode: word clock\n");
} else if (rme96->wcreg & RME96_WCR_MASTER) {
snd_iprintf(buffer, " clock mode: master\n");
+ } else if (snd_rme96_getinputtype(rme96) == RME96_INPUT_ANALOG) {
+ snd_iprintf(buffer, " clock mode: slave (master anyway due to analog input setting)\n");
+ } else if (snd_rme96_capture_getrate(rme96, &n) < 0) {
+ snd_iprintf(buffer, " clock mode: slave (master anyway due to no valid signal)\n");
} else {
snd_iprintf(buffer, " clock mode: slave\n");
}
{
rme96_t *rme96 = _snd_kcontrol_chip(kcontrol);
unsigned long flags;
- int items = 3;
+ unsigned int items = 3;
spin_lock_irqsave(&rme96->lock, flags);
ucontrol->value.enumerated.item[0] = snd_rme96_getinputtype(rme96);
}
spin_lock_irqsave(&rme96->lock, flags);
- change = val != snd_rme96_getinputtype(rme96);
+ change = (int)val != snd_rme96_getinputtype(rme96);
snd_rme96_setinputtype(rme96, val);
spin_unlock_irqrestore(&rme96->lock, flags);
return change;
val = ucontrol->value.enumerated.item[0] % 3;
spin_lock_irqsave(&rme96->lock, flags);
- change = val != snd_rme96_getclockmode(rme96);
+ change = (int)val != snd_rme96_getclockmode(rme96);
snd_rme96_setclockmode(rme96, val);
spin_unlock_irqrestore(&rme96->lock, flags);
return change;
val = ucontrol->value.enumerated.item[0] % 4;
spin_lock_irqsave(&rme96->lock, flags);
- change = val != snd_rme96_getattenuation(rme96);
+
+ change = (int)val != snd_rme96_getattenuation(rme96);
snd_rme96_setattenuation(rme96, val);
spin_unlock_irqrestore(&rme96->lock, flags);
return change;
val = ucontrol->value.enumerated.item[0] % 4;
spin_lock_irqsave(&rme96->lock, flags);
- change = val != snd_rme96_getmontracks(rme96);
+ change = (int)val != snd_rme96_getmontracks(rme96);
snd_rme96_setmontracks(rme96, val);
spin_unlock_irqrestore(&rme96->lock, flags);
return change;
*/
for (i = 0; i < timeout; i++)
- if ((hdsp_read (hdsp, HDSP_fifoStatus) & 0xff) <= count)
+ if ((int)(hdsp_read (hdsp, HDSP_fifoStatus) & 0xff) <= count)
return 0;
snd_printk ("wait for FIFO status <= %d failed after %d iterations\n",
{
unsigned long flags;
int n_pending;
- int clear_timer = 0;
int to_write;
int i;
unsigned char buf[128];
if (hmidi->output) {
if (!snd_rawmidi_transmit_empty (hmidi->output)) {
if ((n_pending = snd_hdsp_midi_output_possible (hmidi->hdsp, hmidi->id)) > 0) {
- if (n_pending > sizeof (buf))
+ if (n_pending > (int)sizeof (buf))
n_pending = sizeof (buf);
if ((to_write = snd_rawmidi_transmit (hmidi->output, buf, n_pending)) > 0) {
for (i = 0; i < to_write; ++i)
snd_hdsp_midi_write_byte (hmidi->hdsp, hmidi->id, buf[i]);
- } else {
- clear_timer = 1;
}
}
- } else {
- clear_timer = 1;
}
-
- if (clear_timer && hmidi->istimer && --hmidi->istimer <= 0) {
- del_timer(&hmidi->timer);
- }
}
spin_unlock_irqrestore (&hmidi->lock, flags);
if ((n_pending = snd_hdsp_midi_input_available (hmidi->hdsp, hmidi->id)) > 0) {
if (hmidi->input) {
- if (n_pending > sizeof (buf)) {
+ if (n_pending > (int)sizeof (buf)) {
n_pending = sizeof (buf);
}
for (i = 0; i < n_pending; ++i) {
}
}
spin_unlock_irqrestore (&hmidi->lock, flags);
+ if (up)
+ snd_hdsp_midi_output_write(hmidi);
}
static int snd_hdsp_midi_input_open(snd_rawmidi_substream_t * substream)
return -EBUSY;
val = ucontrol->value.integer.value[0] & 1;
spin_lock_irqsave(&hdsp->lock, flags);
- change = val != hdsp_spdif_out(hdsp);
+ change = (int)val != hdsp_spdif_out(hdsp);
hdsp_set_spdif_output(hdsp, val);
spin_unlock_irqrestore(&hdsp->lock, flags);
return change;
max = hdsp->ss_channels == (hdsp->type == Digiface) ? 7 : 6;
val = ucontrol->value.enumerated.item[0] % max;
spin_lock_irqsave(&hdsp->lock, flags);
- change = val != hdsp_sync_pref(hdsp);
+ change = (int)val != hdsp_sync_pref(hdsp);
hdsp_set_sync_pref(hdsp, val);
spin_unlock_irqrestore(&hdsp->lock, flags);
return change;
return -EBUSY;
val = ucontrol->value.integer.value[0] & 1;
spin_lock_irqsave(&hdsp->lock, flags);
- change = val != hdsp_line_out(hdsp);
+ change = (int)val != hdsp_line_out(hdsp);
hdsp_set_line_output(hdsp, val);
spin_unlock_irqrestore(&hdsp->lock, flags);
return change;
gain = ucontrol->value.integer.value[2];
spin_lock_irqsave(&hdsp->lock, flags);
- if ((change = gain != hdsp_read_gain(hdsp, addr)))
+ change = gain != hdsp_read_gain(hdsp, addr);
+ if (change)
hdsp_write_gain(hdsp, addr, gain);
spin_unlock_irqrestore(&hdsp->lock, flags);
return change;
spin_lock_irqsave(&hdsp->lock, flags);
- if ((change = gain != hdsp_read_gain(hdsp, addr)))
+ change = gain != hdsp_read_gain(hdsp, addr);
+ if (change)
hdsp_write_gain(hdsp, addr, gain);
spin_unlock_irqrestore(&hdsp->lock, flags);
return change;
int snd_hdsp_create_controls(snd_card_t *card, hdsp_t *hdsp)
{
- int idx, err, limit;
+ unsigned int idx, limit;
+ int err;
snd_kcontrol_t *kctl;
for (idx = 0; idx < HDSP_CONTROLS; idx++) {
that matter are the same.
*/
- if (params_rate(params) != hdsp_system_sample_rate(hdsp)) {
+ if ((int)params_rate(params) != hdsp_system_sample_rate(hdsp)) {
spin_unlock_irq(&hdsp->lock);
_snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_RATE);
return -EBUSY;
.rate_max = 96000,
.channels_min = 14,
.channels_max = HDSP_MAX_CHANNELS,
- .buffer_bytes_max = 1024*1024,
- .period_bytes_min = 1,
- .period_bytes_max = 1024*1024,
+ .buffer_bytes_max = HDSP_CHANNEL_BUFFER_BYTES * HDSP_MAX_CHANNELS,
+ .period_bytes_min = (64 * 4) *10,
+ .period_bytes_max = (8192 * 4) * HDSP_MAX_CHANNELS,
.periods_min = 2,
.periods_max = 2,
.fifo_size = 0,
.rate_max = 96000,
.channels_min = 14,
.channels_max = HDSP_MAX_CHANNELS,
- .buffer_bytes_max = 1024*1024,
- .period_bytes_min = 1,
- .period_bytes_max = 1024*1024,
+ .buffer_bytes_max = HDSP_CHANNEL_BUFFER_BYTES * HDSP_MAX_CHANNELS,
+ .period_bytes_min = (64 * 4) * 10,
+ .period_bytes_max = (8192 * 4) * HDSP_MAX_CHANNELS,
.periods_min = 2,
.periods_max = 2,
.fifo_size = 0,
static snd_pcm_uframes_t rme9652_hw_pointer(rme9652_t *rme9652)
{
int status;
- int offset, frag;
+ unsigned int offset, frag;
snd_pcm_uframes_t period_size = rme9652->period_bytes / 4;
snd_pcm_sframes_t delta;
delta = rme9652->prev_hw_offset - offset;
delta &= 0xffff;
- if (delta <= rme9652->max_jitter * 4)
+ if (delta <= (snd_pcm_sframes_t)rme9652->max_jitter * 4)
offset = rme9652->prev_hw_offset;
else
rme9652->prev_hw_offset = offset;
return -EBUSY;
val = ucontrol->value.integer.value[0] & 1;
spin_lock_irqsave(&rme9652->lock, flags);
- change = val != rme9652_spdif_out(rme9652);
+ change = (int)val != rme9652_spdif_out(rme9652);
rme9652_set_spdif_output(rme9652, val);
spin_unlock_irqrestore(&rme9652->lock, flags);
return change;
val = ucontrol->value.enumerated.item[0] % 3;
spin_lock_irqsave(&rme9652->lock, flags);
- change = val != rme9652_sync_mode(rme9652);
+ change = (int)val != rme9652_sync_mode(rme9652);
rme9652_set_sync_mode(rme9652, val);
spin_unlock_irqrestore(&rme9652->lock, flags);
return change;
max = rme9652->ss_channels == RME9652_NCHANNELS ? 4 : 3;
val = ucontrol->value.enumerated.item[0] % max;
spin_lock_irqsave(&rme9652->lock, flags);
- change = val != rme9652_sync_pref(rme9652);
+ change = (int)val != rme9652_sync_pref(rme9652);
rme9652_set_sync_pref(rme9652, val);
spin_unlock_irqrestore(&rme9652->lock, flags);
return change;
int snd_rme9652_create_controls(snd_card_t *card, rme9652_t *rme9652)
{
- int idx, err;
+ unsigned int idx;
+ int err;
snd_kcontrol_t *kctl;
for (idx = 0; idx < RME9652_CONTROLS; idx++) {
that matter are the same.
*/
- if (params_rate(params) !=
+ if ((int)params_rate(params) !=
rme9652_adat_sample_rate(rme9652)) {
spin_unlock_irq(&rme9652->lock);
_snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_RATE);
.rate_max = 96000,
.channels_min = 10,
.channels_max = 26,
- .buffer_bytes_max = 1024*1024,
- .period_bytes_min = 1,
- .period_bytes_max = 1024*1024,
+ .buffer_bytes_max = RME9652_CHANNEL_BUFFER_BYTES * 26,
+ .period_bytes_min = (64 * 4) * 10,
+ .period_bytes_max = (8192 * 4) * 26,
.periods_min = 2,
.periods_max = 2,
.fifo_size = 0,
.rate_max = 96000,
.channels_min = 10,
.channels_max = 26,
- .buffer_bytes_max = 1024*1024,
- .period_bytes_min = 1,
- .period_bytes_max = 1024*1024,
+ .buffer_bytes_max = RME9652_CHANNEL_BUFFER_BYTES *26,
+ .period_bytes_min = (64 * 4) * 10,
+ .period_bytes_max = (8192 * 4) * 26,
.periods_min = 2,
.periods_max = 2,
.fifo_size = 0,
{
snd_card_t *card;
snd_kcontrol_t *kctl;
- int idx, err;
+ unsigned int idx;
+ int err;
snd_assert(sonic != NULL && sonic->card != NULL, return -EINVAL);
card = sonic->card;
mpu401_t * mpu = snd_magic_cast(mpu401_t, rmidi->private_data, return -ENXIO);
snd_card_t *card = sonic->card;
snd_rawmidi_str_t *dir;
- int idx, err;
+ unsigned int idx;
+ int err;
mpu->private_data = sonic;
mpu->open_input = snd_sonicvibes_midi_input_open;
# <empty string> - CONFIG_SND_SEQUENCER is undefined
# otherwise parameter #1 value
#
-sequencer := $(if $(subst y,,$(CONFIG_SND_SEQUENCER)),m,$(if $(CONFIG_SND_SEQUENCER),$(1)))
+sequencer = $(if $(subst y,,$(CONFIG_SND_SEQUENCER)),$(if $(1),m),$(if $(CONFIG_SND_SEQUENCER),$(1)))
# Toplevel Module Dependency
obj-$(CONFIG_SND_TRIDENT) += snd-trident.o
cso = (unsigned int) inl(TRID_REG(trident, CH_NX_DELTA_CSO)) & 0x00ffffff;
}
- if (++cso > runtime->buffer_size)
- cso = runtime->buffer_size;
-
spin_unlock(&trident->reg_lock);
+ if (++cso >= runtime->buffer_size)
+ cso = 0;
+
return cso;
}
result = inw(TRID_REG(trident, T4D_SBBL_SBCL));
if (runtime->channels > 1)
result >>= 1;
- result = runtime->buffer_size - result;
+ if (result > 0)
+ result = runtime->buffer_size - result;
// printk("capture result = 0x%x, cso = 0x%x\n", result, cso);
delta = (int)stimer - (int)voice->stimer;
if (delta < 0)
delta = -delta;
- if (delta < voice->spurious_threshold) {
+ if ((unsigned int)delta < voice->spurious_threshold) {
/* do some statistics here */
trident->spurious_irq_count++;
- if (trident->spurious_irq_max_delta < delta)
+ if (trident->spurious_irq_max_delta < (unsigned int)delta)
trident->spurious_irq_max_delta = delta;
continue;
}
break;
} else { /* attenuate right (pan left) */
for (voice->Pan = 0; voice->Pan < 63; voice->Pan++ )
- if (volume->lr >= pan_table[voice->Pan] )
+ if ((unsigned int)volume->lr >= pan_table[voice->Pan] )
break;
voice->Pan |= 0x40;
}
snd_trident_port_t *port = (snd_trident_port_t *) private_data;
trident_t *trident = port->trident;
snd_trident_voice_t *voice;
- int idx;
+ unsigned int idx;
unsigned long flags;
if (info->voices > 32)
SNDRV_SEQ_PORT_TYPE_MIDI_GS |
SNDRV_SEQ_PORT_TYPE_DIRECT_SAMPLE |
SNDRV_SEQ_PORT_TYPE_SYNTH,
+ 16,
name);
if (p->chset->port < 0) {
result = p->chset->port;
MODULE_PARM(mpu_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
MODULE_PARM_DESC(mpu_port, "MPU-401 port.");
MODULE_PARM_SYNTAX(mpu_port, SNDRV_PORT_DESC);
-MODULE_PARM(ac97_clock, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
+MODULE_PARM(ac97_clock, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz).");
MODULE_PARM_SYNTAX(ac97_clock, SNDRV_ENABLED ",default:48000");
#define PCI_DEVICE_ID_VIA_8233_5 0x3059
#endif
+/* revision numbers for via686 */
+#define VIA_REV_686_A 0x10
+#define VIA_REV_686_B 0x11
+#define VIA_REV_686_C 0x12
+#define VIA_REV_686_D 0x13
+#define VIA_REV_686_E 0x14
+#define VIA_REV_686_H 0x20
+
/* revision numbers for via8233 */
#define VIA_REV_PRE_8233 0x10 /* not in market */
#define VIA_REV_8233C 0x20 /* 2 rec, 4 pb, 1 multi-pb */
*/
#define VIAREG(via, x) ((via)->port + VIA_REG_##x)
+#define VIADEV_REG(viadev, x) ((viadev)->port + VIA_REG_##x)
/* common offsets */
#define VIA_REG_OFFSET_STATUS 0x00 /* byte - channel status */
#define VIA_REG_AC97_CMD_MASK 0x7e
#define VIA_REG_AC97_DATA_SHIFT 0
#define VIA_REG_AC97_DATA_MASK 0xffff
+
#define VIA_REG_SGD_SHADOW 0x84 /* dword */
+/* via686 */
+#define VIA_REG_SGD_STAT_PB_FLAG (1<<0)
+#define VIA_REG_SGD_STAT_CP_FLAG (1<<1)
+#define VIA_REG_SGD_STAT_FM_FLAG (1<<2)
+#define VIA_REG_SGD_STAT_PB_EOL (1<<4)
+#define VIA_REG_SGD_STAT_CP_EOL (1<<5)
+#define VIA_REG_SGD_STAT_FM_EOL (1<<6)
+#define VIA_REG_SGD_STAT_PB_STOP (1<<8)
+#define VIA_REG_SGD_STAT_CP_STOP (1<<9)
+#define VIA_REG_SGD_STAT_FM_STOP (1<<10)
+#define VIA_REG_SGD_STAT_PB_ACTIVE (1<<12)
+#define VIA_REG_SGD_STAT_CP_ACTIVE (1<<13)
+#define VIA_REG_SGD_STAT_FM_ACTIVE (1<<14)
+/* via8233 */
+#define VIA8233_REG_SGD_STAT_FLAG (1<<0)
+#define VIA8233_REG_SGD_STAT_EOL (1<<1)
+#define VIA8233_REG_SGD_STAT_STOP (1<<2)
+#define VIA8233_REG_SGD_STAT_ACTIVE (1<<3)
+#define VIA8233_REG_SGD_SDX0_SHIFT 0
+#define VIA8233_REG_SGD_SDX1_SHIFT 4
+#define VIA8233_REG_SGD_SDX2_SHIFT 8
+#define VIA8233_REG_SGD_SDX3_SHIFT 12
+#define VIA8233_REG_SGD_MCHAN_SHIFT 16
+#define VIA8233_REG_SGD_REC0_SHIFT 24
+#define VIA8233_REG_SGD_REC1_SHIFT 28
+
+#define VIA_REG_GPI_STATUS 0x88
+#define VIA_REG_GPI_INTR 0x8c
/* multi-channel and capture registers for via8233 */
DEFINE_VIA_REGSET(MULTPLAY, 0x40);
DEFINE_VIA_REGSET(CAPTURE_8233, 0x60);
/* via8233-specific registers */
-#define VIA_REG_PLAYBACK_VOLUME_L 0x02 /* byte */
-#define VIA_REG_PLAYBACK_VOLUME_R 0x03 /* byte */
-#define VIA_REG_MULTPLAY_FORMAT 0x42 /* byte - format and channels */
+#define VIA_REG_OFS_PLAYBACK_VOLUME_L 0x02 /* byte */
+#define VIA_REG_OFS_PLAYBACK_VOLUME_R 0x03 /* byte */
+#define VIA_REG_OFS_MULTPLAY_FORMAT 0x02 /* byte - format and channels */
#define VIA_REG_MULTPLAY_FMT_8BIT 0x00
#define VIA_REG_MULTPLAY_FMT_16BIT 0x80
#define VIA_REG_MULTPLAY_FMT_CH_MASK 0x70 /* # channels << 4 (valid = 1,2,4,6) */
-#define VIA_REG_CAPTURE_FIFO 0x62 /* byte - bit 6 = fifo enable */
+#define VIA_REG_OFS_CAPTURE_FIFO 0x62 /* byte - bit 6 = fifo enable */
#define VIA_REG_CAPTURE_FIFO_ENABLE 0x40
+
#define VIA_REG_CAPTURE_CHANNEL 0x63 /* byte - input select */
#define VIA_REG_CAPTURE_CHANNEL_MIC 0x4
#define VIA_REG_CAPTURE_CHANNEL_LINE 0
#define VIA_TBL_BIT_FLAG 0x40000000
#define VIA_TBL_BIT_EOL 0x80000000
+/* pci space */
+#define VIA_ACLINK_STAT 0x40
+#define VIA_ACLINK_C11_READY 0x20
+#define VIA_ACLINK_C10_READY 0x10
+#define VIA_ACLINK_C01_READY 0x04 /* secondary codec ready */
+#define VIA_ACLINK_LOWPOWER 0x02 /* low-power state */
+#define VIA_ACLINK_C00_READY 0x01 /* primary codec ready */
+#define VIA_ACLINK_CTRL 0x41
+#define VIA_ACLINK_CTRL_ENABLE 0x80 /* 0: disable, 1: enable */
+#define VIA_ACLINK_CTRL_RESET 0x40 /* 0: assert, 1: de-assert */
+#define VIA_ACLINK_CTRL_SYNC 0x20 /* 0: release SYNC, 1: force SYNC hi */
+#define VIA_ACLINK_CTRL_SDO 0x10 /* 0: release SDO, 1: force SDO hi */
+#define VIA_ACLINK_CTRL_VRA 0x08 /* 0: disable VRA, 1: enable VRA */
+#define VIA_ACLINK_CTRL_PCM 0x04 /* 0: disable PCM, 1: enable PCM */
+#define VIA_ACLINK_CTRL_FM 0x02 /* via686 only */
+#define VIA_ACLINK_CTRL_SB 0x01 /* via686 only */
+#define VIA_ACLINK_CTRL_INIT (VIA_ACLINK_CTRL_ENABLE|\
+ VIA_ACLINK_CTRL_RESET|\
+ VIA_ACLINK_CTRL_PCM|\
+ VIA_ACLINK_CTRL_VRA)
+#define VIA_FUNC_ENABLE 0x42
+#define VIA_FUNC_MIDI_PNP 0x80 /* FIXME: it's 0x40 in the datasheet! */
+#define VIA_FUNC_MIDI_IRQMASK 0x40 /* FIXME: not documented! */
+#define VIA_FUNC_RX2C_WRITE 0x20
+#define VIA_FUNC_SB_FIFO_EMPTY 0x10
+#define VIA_FUNC_ENABLE_GAME 0x08
+#define VIA_FUNC_ENABLE_FM 0x04
+#define VIA_FUNC_ENABLE_MIDI 0x02
+#define VIA_FUNC_ENABLE_SB 0x01
+#define VIA_PNP_CONTROL 0x43
+#define VIA_FM_NMI_CTRL 0x48
+#define VIA8233_VOLCHG_CTRL 0x48
+#define VIA8233_SPDIF_CTRL 0x49
+#define VIA8233_SPDIF_DX3 0x08
+#define VIA8233_SPDIF_SLOT_MASK 0x03
+#define VIA8233_SPDIF_SLOT_1011 0x00
+#define VIA8233_SPDIF_SLOT_34 0x01
+#define VIA8233_SPDIF_SLOT_78 0x02
+#define VIA8233_SPDIF_SLOT_69 0x03
+
/*
*/
struct via_dev {
unsigned int reg_offset;
+ unsigned long port;
int direction; /* playback = 0, capture = 1 */
snd_pcm_substream_t *substream;
int running;
/*
*/
-enum { TYPE_VIA686 = 1, TYPE_VIA8233 };
+enum { TYPE_CARD_VIA686 = 1, TYPE_CARD_VIA8233 };
+enum { TYPE_VIA686, TYPE_VIA8233, TYPE_VIA8233A };
#define VIA_MAX_DEVS 7 /* 4 playback, 1 multi, 2 capture */
unsigned char old_legacy;
unsigned char old_legacy_cfg;
+ unsigned char playback_volume[2]; /* for VIA8233/C/8235; default = 0 */
+
+ unsigned int intr_mask; /* SGD_SHADOW mask to check interrupts */
+
struct pci_dev *pci;
snd_card_t *card;
- int num_devs;
- int playback_devno, multi_devno, capture_devno;
+ unsigned int num_devs;
+ unsigned int playback_devno, multi_devno, capture_devno;
viadev_t devs[VIA_MAX_DEVS];
struct via_rate_lock rates[2]; /* playback and capture */
};
static struct pci_device_id snd_via82xx_ids[] __devinitdata = {
- { 0x1106, 0x3058, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_VIA686, }, /* 686A */
- { 0x1106, 0x3059, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_VIA8233, }, /* VT8233 */
+ { 0x1106, 0x3058, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_CARD_VIA686, }, /* 686A */
+ { 0x1106, 0x3059, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_CARD_VIA8233, }, /* VT8233 */
{ 0, }
};
static void snd_via82xx_channel_reset(via82xx_t *chip, viadev_t *viadev)
{
- unsigned long port = chip->port + viadev->reg_offset;
-
- outb(VIA_REG_CTRL_PAUSE | VIA_REG_CTRL_TERMINATE | VIA_REG_CTRL_RESET, port + VIA_REG_OFFSET_CONTROL);
+ outb(VIA_REG_CTRL_PAUSE | VIA_REG_CTRL_TERMINATE | VIA_REG_CTRL_RESET,
+ VIADEV_REG(viadev, OFFSET_CONTROL));
udelay(50);
/* disable interrupts */
- outb(0x00, port + VIA_REG_OFFSET_CONTROL);
+ outb(0x00, VIADEV_REG(viadev, OFFSET_CONTROL));
/* clear interrupts */
- outb(0x03, port + VIA_REG_OFFSET_STATUS);
- outb(0x00, port + VIA_REG_OFFSET_TYPE); /* for via686 */
- outl(0, port + VIA_REG_OFFSET_CURR_PTR);
+ outb(0x03, VIADEV_REG(viadev, OFFSET_STATUS));
+ outb(0x00, VIADEV_REG(viadev, OFFSET_TYPE)); /* for via686 */
+ // outl(0, VIADEV_REG(viadev, OFFSET_CURR_PTR));
viadev->lastpos = 0;
}
{
via82xx_t *chip = snd_magic_cast(via82xx_t, dev_id, return);
unsigned int status;
- int i;
+ unsigned int i;
spin_lock(&chip->reg_lock);
- if (chip->chip_type == TYPE_VIA686) {
- /* check mpu401 interrupt */
- status = inl(VIAREG(chip, SGD_SHADOW));
- if ((status & 0x00000077) == 0) {
- spin_unlock(&chip->reg_lock);
- if (chip->rmidi != NULL)
- snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data, regs);
- return;
- }
+ status = inl(VIAREG(chip, SGD_SHADOW));
+ if (! (status & chip->intr_mask)) {
+ spin_unlock(&chip->reg_lock);
+ if (chip->rmidi)
+ /* check mpu401 interrupt */
+ snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data, regs);
+ return;
}
+
/* check status for each stream */
for (i = 0; i < chip->num_devs; i++) {
viadev_t *viadev = &chip->devs[i];
- if (inb(chip->port + viadev->reg_offset) & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG)) {
- outb(VIA_REG_STAT_FLAG | VIA_REG_STAT_EOL, VIAREG(chip, OFFSET_STATUS) + viadev->reg_offset);
- if (viadev->substream && viadev->running) {
- spin_unlock(&chip->reg_lock);
- snd_pcm_period_elapsed(viadev->substream);
- spin_lock(&chip->reg_lock);
- }
+ unsigned char status = inb(VIADEV_REG(viadev, OFFSET_STATUS));
+ status &= (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG);
+ if (! status)
+ continue;
+ outb(status, VIADEV_REG(viadev, OFFSET_STATUS)); /* ack */
+ if (viadev->substream && viadev->running) {
+ spin_unlock(&chip->reg_lock);
+ snd_pcm_period_elapsed(viadev->substream);
+ spin_lock(&chip->reg_lock);
}
}
spin_unlock(&chip->reg_lock);
via82xx_t *chip = snd_pcm_substream_chip(substream);
viadev_t *viadev = (viadev_t *)substream->runtime->private_data;
unsigned char val;
- unsigned long port = chip->port + viadev->reg_offset;
- if (chip->chip_type == TYPE_VIA8233)
+ if (chip->chip_type != TYPE_VIA686)
val = VIA_REG_CTRL_INT;
else
val = 0;
default:
return -EINVAL;
}
- outb(val, port + VIA_REG_OFFSET_CONTROL);
+ outb(val, VIADEV_REG(viadev, OFFSET_CONTROL));
if (cmd == SNDRV_PCM_TRIGGER_STOP)
snd_via82xx_channel_reset(chip, viadev);
return 0;
unsigned int idx, ptr, count, res;
snd_assert(viadev->tbl_entries, return 0);
- if (!(inb(VIAREG(chip, OFFSET_STATUS) + viadev->reg_offset) & VIA_REG_STAT_ACTIVE))
+ if (!(inb(VIADEV_REG(viadev, OFFSET_STATUS)) & VIA_REG_STAT_ACTIVE))
return 0;
spin_lock(&chip->reg_lock);
- count = inl(VIAREG(chip, OFFSET_CURR_COUNT) + viadev->reg_offset) & 0xffffff;
+ count = inl(VIADEV_REG(viadev, OFFSET_CURR_COUNT)) & 0xffffff;
/* The via686a does not have the current index register,
* so we need to calculate the index from CURR_PTR.
*/
- ptr = inl(VIAREG(chip, OFFSET_CURR_PTR) + viadev->reg_offset);
+ ptr = inl(VIADEV_REG(viadev, OFFSET_CURR_PTR));
if (ptr <= (unsigned int)viadev->table_addr)
idx = 0;
else /* CURR_PTR holds the address + 8 */
unsigned int idx, count, res;
snd_assert(viadev->tbl_entries, return 0);
- if (!(inb(VIAREG(chip, OFFSET_STATUS) + viadev->reg_offset) & VIA_REG_STAT_ACTIVE))
+ if (!(inb(VIADEV_REG(viadev, OFFSET_STATUS)) & VIA_REG_STAT_ACTIVE))
return 0;
spin_lock(&chip->reg_lock);
- count = inl(VIAREG(chip, OFFSET_CURR_COUNT) + viadev->reg_offset);
+ count = inl(VIADEV_REG(viadev, OFFSET_CURR_COUNT));
idx = count >> 24;
- count &= 0xffffff;
- res = calc_linear_pos(viadev, idx, count);
+ if (idx >= viadev->tbl_entries) {
+#ifdef POINTER_DEBUG
+ printk("fail: invalid idx = %i/%i\n", idx, viadev->tbl_entries);
+#endif
+ res = viadev->lastpos;
+ } else {
+ count &= 0xffffff;
+ res = calc_linear_pos(viadev, idx, count);
+ }
spin_unlock(&chip->reg_lock);
return bytes_to_frames(substream->runtime, res);
}
+/*
+ * set up the table pointer
+ */
+static void snd_via82xx_set_table_ptr(via82xx_t *chip, viadev_t *viadev)
+{
+ snd_via82xx_codec_ready(chip, 0);
+ outl((u32)viadev->table_addr, VIADEV_REG(viadev, OFFSET_TABLE_PTR));
+ udelay(20);
+ snd_via82xx_codec_ready(chip, 0);
+}
+
/*
* prepare callback for playback and capture on via686
*/
static void via686_setup_format(via82xx_t *chip, viadev_t *viadev, snd_pcm_runtime_t *runtime)
{
- unsigned long port = chip->port + viadev->reg_offset;
-
snd_via82xx_channel_reset(chip, viadev);
/* this must be set after channel_reset */
- outl((u32)viadev->table_addr, port + VIA_REG_OFFSET_TABLE_PTR);
+ snd_via82xx_set_table_ptr(chip, viadev);
outb(VIA_REG_TYPE_AUTOSTART |
(runtime->format == SNDRV_PCM_FORMAT_S16_LE ? VIA_REG_TYPE_16BIT : 0) |
(runtime->channels > 1 ? VIA_REG_TYPE_STEREO : 0) |
((viadev->reg_offset & 0x10) == 0 ? VIA_REG_TYPE_INT_LSAMPLE : 0) |
VIA_REG_TYPE_INT_EOL |
- VIA_REG_TYPE_INT_FLAG, port + VIA_REG_OFFSET_TYPE);
+ VIA_REG_TYPE_INT_FLAG, VIADEV_REG(viadev, OFFSET_TYPE));
}
static int snd_via686_playback_prepare(snd_pcm_substream_t *substream)
{
via82xx_t *chip = snd_pcm_substream_chip(substream);
viadev_t *viadev = (viadev_t *)substream->runtime->private_data;
- unsigned long port = chip->port + viadev->reg_offset;
snd_pcm_runtime_t *runtime = substream->runtime;
int rate_changed;
u32 rbits;
rbits = (0xfffff / 48000) * runtime->rate + ((0xfffff % 48000) * runtime->rate) / 48000;
snd_assert((rbits & ~0xfffff) == 0, return -EINVAL);
snd_via82xx_channel_reset(chip, viadev);
- outl((u32)viadev->table_addr, port + VIA_REG_OFFSET_TABLE_PTR);
- outb(0 , VIAREG(chip, PLAYBACK_VOLUME_L));
- outb(0 , VIAREG(chip, PLAYBACK_VOLUME_R));
+ snd_via82xx_set_table_ptr(chip, viadev);
+ outb(chip->playback_volume[0], VIADEV_REG(viadev, OFS_PLAYBACK_VOLUME_L));
+ outb(chip->playback_volume[1], VIADEV_REG(viadev, OFS_PLAYBACK_VOLUME_R));
outl((runtime->format == SNDRV_PCM_FORMAT_S16_LE ? VIA8233_REG_TYPE_16BIT : 0) | /* format */
(runtime->channels > 1 ? VIA8233_REG_TYPE_STEREO : 0) | /* stereo */
rbits | /* rate */
0xff000000, /* STOP index is never reached */
- port + VIA_REG_OFFSET_STOP_IDX);
+ VIADEV_REG(viadev, OFFSET_STOP_IDX));
+ udelay(20);
+ snd_via82xx_codec_ready(chip, 0);
return 0;
}
{
via82xx_t *chip = snd_pcm_substream_chip(substream);
viadev_t *viadev = (viadev_t *)substream->runtime->private_data;
- unsigned long port = chip->port + viadev->reg_offset;
snd_pcm_runtime_t *runtime = substream->runtime;
unsigned int slots;
int fmt;
snd_ac97_set_rate(chip->ac97, AC97_PCM_LFE_DAC_RATE, runtime->rate);
snd_ac97_set_rate(chip->ac97, AC97_SPDIF, runtime->rate);
snd_via82xx_channel_reset(chip, viadev);
- outl((u32)viadev->table_addr, port + VIA_REG_OFFSET_TABLE_PTR);
+ snd_via82xx_set_table_ptr(chip, viadev);
fmt = (runtime->format == SNDRV_PCM_FORMAT_S16_LE) ? VIA_REG_MULTPLAY_FMT_16BIT : VIA_REG_MULTPLAY_FMT_8BIT;
fmt |= runtime->channels << 4;
- outb(fmt, port + VIA_REG_OFFSET_TYPE);
+ outb(fmt, VIADEV_REG(viadev, OFS_MULTPLAY_FORMAT));
/* set sample number to slot 3, 4, 7, 8, 6, 9 */
/* corresponding to FL, FR, RL, RR, C, LFE ?? */
switch (runtime->channels) {
default: slots = 0; break;
}
/* STOP index is never reached */
- outl(0xff000000 | slots, port + VIA_REG_OFFSET_STOP_IDX);
+ outl(0xff000000 | slots, VIADEV_REG(viadev, OFFSET_STOP_IDX));
+ udelay(20);
+ snd_via82xx_codec_ready(chip, 0);
return 0;
}
{
via82xx_t *chip = snd_pcm_substream_chip(substream);
viadev_t *viadev = (viadev_t *)substream->runtime->private_data;
- unsigned long port = chip->port + viadev->reg_offset;
snd_pcm_runtime_t *runtime = substream->runtime;
if (via_lock_rate(&chip->rates[1], runtime->rate) < 0)
return -EINVAL;
snd_ac97_set_rate(chip->ac97, AC97_PCM_LR_ADC_RATE, runtime->rate);
snd_via82xx_channel_reset(chip, viadev);
- outl((u32)viadev->table_addr, port + VIA_REG_OFFSET_TABLE_PTR);
- outb(VIA_REG_CAPTURE_FIFO_ENABLE, VIAREG(chip, CAPTURE_FIFO));
+ snd_via82xx_set_table_ptr(chip, viadev);
+ outb(VIA_REG_CAPTURE_FIFO_ENABLE, VIADEV_REG(viadev, OFS_CAPTURE_FIFO));
outl((runtime->format == SNDRV_PCM_FORMAT_S16_LE ? VIA8233_REG_TYPE_16BIT : 0) |
(runtime->channels > 1 ? VIA8233_REG_TYPE_STEREO : 0) |
0xff000000, /* STOP index is never reached */
- port + VIA_REG_OFFSET_STOP_IDX);
+ VIADEV_REG(viadev, OFFSET_STOP_IDX));
+ udelay(20);
+ snd_via82xx_codec_ready(chip, 0);
return 0;
}
if ((err = snd_via82xx_pcm_open(chip, viadev, substream)) < 0)
return err;
substream->runtime->hw.channels_max = 6;
- if (chip->revision == VIA_REV_8233A)
+ if (chip->chip_type == TYPE_VIA8233A)
snd_pcm_hw_constraint_list(substream->runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, &hw_constraints_channels);
return 0;
}
};
+static void init_viadev(via82xx_t *chip, int idx, unsigned int reg_offset, int direction)
+{
+ chip->devs[idx].reg_offset = reg_offset;
+ chip->devs[idx].direction = direction;
+ chip->devs[idx].port = chip->port + reg_offset;
+}
+
/*
* create pcm instances for VIA8233, 8233C and 8235 (not 8233A)
*/
chip->multi_devno = 4; /* x 1 */
chip->capture_devno = 5; /* x 2 */
chip->num_devs = 7;
+ chip->intr_mask = 0x33033333; /* FLAG|EOL for rec0-1, mc, sdx0-3 */
/* PCM #0: 4 DSX playbacks and 1 capture */
err = snd_pcm_new(chip->card, chip->card->shortname, 0, 4, 1, &pcm);
pcm->private_data = chip;
strcpy(pcm->name, chip->card->shortname);
/* set up playbacks */
- for (i = 0; i < 4; i++) {
- chip->devs[i].reg_offset = 0x10 * i;
- chip->devs[i].direction = 0;
- }
+ for (i = 0; i < 4; i++)
+ init_viadev(chip, i, 0x10 * i, 0);
/* capture */
- chip->devs[chip->capture_devno].reg_offset = VIA_REG_CAPTURE_8233_STATUS;
- chip->devs[chip->capture_devno].direction = 1;
+ init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 1);
if ((err = snd_pcm_lib_preallocate_sg_pages_for_all(chip->pci, pcm)) < 0)
return err;
pcm->private_data = chip;
strcpy(pcm->name, chip->card->shortname);
/* set up playback */
- chip->devs[chip->multi_devno].reg_offset = VIA_REG_MULTPLAY_STATUS;
- chip->devs[chip->multi_devno].direction = 0;
+ init_viadev(chip, chip->multi_devno, VIA_REG_MULTPLAY_STATUS, 0);
/* set up capture */
- chip->devs[chip->capture_devno + 1].reg_offset = VIA_REG_CAPTURE_8233_STATUS + 0x10;
- chip->devs[chip->capture_devno + 1].direction = 1;
+ init_viadev(chip, chip->capture_devno + 1, VIA_REG_CAPTURE_8233_STATUS + 0x10, 1);
if ((err = snd_pcm_lib_preallocate_sg_pages_for_all(chip->pci, pcm)) < 0)
return err;
snd_pcm_t *pcm;
int err;
- chip->playback_devno = 0;
- chip->multi_devno = 1;
+ chip->multi_devno = 0;
+ chip->playback_devno = 1;
chip->capture_devno = 2;
chip->num_devs = 3;
+ chip->intr_mask = 0x03033000; /* FLAG|EOL for rec0, mc, sdx3 */
/* PCM #0: multi-channel playback and capture */
err = snd_pcm_new(chip->card, chip->card->shortname, 0, 1, 1, &pcm);
pcm->private_data = chip;
strcpy(pcm->name, chip->card->shortname);
/* set up playback */
- chip->devs[chip->multi_devno].reg_offset = VIA_REG_MULTPLAY_STATUS;
- chip->devs[chip->multi_devno].direction = 0;
+ init_viadev(chip, chip->multi_devno, VIA_REG_MULTPLAY_STATUS, 0);
/* capture */
- chip->devs[chip->capture_devno].reg_offset = VIA_REG_CAPTURE_8233_STATUS;
- chip->devs[chip->capture_devno].direction = 1;
+ init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 1);
if ((err = snd_pcm_lib_preallocate_sg_pages_for_all(chip->pci, pcm)) < 0)
return err;
pcm->private_data = chip;
strcpy(pcm->name, chip->card->shortname);
/* set up playback */
- chip->devs[chip->playback_devno].reg_offset = 0x30;
- chip->devs[chip->playback_devno].direction = 0;
+ init_viadev(chip, chip->playback_devno, 0x30, 0);
if ((err = snd_pcm_lib_preallocate_sg_pages_for_all(chip->pci, pcm)) < 0)
return err;
chip->playback_devno = 0;
chip->capture_devno = 1;
chip->num_devs = 2;
+ chip->intr_mask = 0x77; /* FLAG | EOL for PB, CP, FM */
err = snd_pcm_new(chip->card, chip->card->shortname, 0, 1, 1, &pcm);
if (err < 0)
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_via686_capture_ops);
pcm->private_data = chip;
strcpy(pcm->name, chip->card->shortname);
- chip->devs[0].reg_offset = VIA_REG_PLAYBACK_STATUS;
- chip->devs[0].direction = 0;
- chip->devs[1].reg_offset = VIA_REG_CAPTURE_STATUS;
- chip->devs[1].direction = 1;
+ init_viadev(chip, 0, VIA_REG_PLAYBACK_STATUS, 0);
+ init_viadev(chip, 1, VIA_REG_CAPTURE_STATUS, 1);
if ((err = snd_pcm_lib_preallocate_sg_pages_for_all(chip->pci, pcm)) < 0)
return err;
via82xx_t *chip = snd_kcontrol_chip(kcontrol);
u8 val;
- pci_read_config_byte(chip->pci, 0x49, &val);
- ucontrol->value.integer.value[0] = (val & 0x08) ? 1 : 0;
+ pci_read_config_byte(chip->pci, VIA8233_SPDIF_CTRL, &val);
+ ucontrol->value.integer.value[0] = (val & VIA8233_SPDIF_DX3) ? 1 : 0;
return 0;
}
via82xx_t *chip = snd_kcontrol_chip(kcontrol);
u8 val, oval;
- pci_read_config_byte(chip->pci, 0x49, &oval);
- val = oval & ~0x08;
+ pci_read_config_byte(chip->pci, VIA8233_SPDIF_CTRL, &oval);
+ val = oval & ~VIA8233_SPDIF_DX3;
if (ucontrol->value.integer.value[0])
- val |= 0x08;
+ val |= VIA8233_SPDIF_DX3;
if (val != oval) {
- pci_write_config_byte(chip->pci, 0x49, val);
+ pci_write_config_byte(chip->pci, VIA8233_SPDIF_CTRL, val);
return 1;
}
return 0;
.put = snd_via8233_dxs3_spdif_put,
};
+static int snd_via8233_dxs_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
+{
+ uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+ uinfo->count = 2;
+ uinfo->value.integer.min = 0;
+ uinfo->value.integer.max = 0xff;
+ return 0;
+}
+
+static int snd_via8233_dxs_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+ via82xx_t *chip = snd_kcontrol_chip(kcontrol);
+ ucontrol->value.integer.value[0] = 0xff - chip->playback_volume[0];
+ ucontrol->value.integer.value[1] = 0xff - chip->playback_volume[1];
+ return 0;
+}
+
+static int snd_via8233_dxs_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+ via82xx_t *chip = snd_kcontrol_chip(kcontrol);
+ unsigned char val;
+ int change;
+
+ val = 0xff - ucontrol->value.integer.value[0];
+ change = val != chip->playback_volume[0];
+ if (val)
+ chip->playback_volume[0] = val;
+ val = 0xff - ucontrol->value.integer.value[1];
+ change |= val != chip->playback_volume[1];
+ if (val)
+ chip->playback_volume[1] = val;
+ return change;
+}
+
+static snd_kcontrol_new_t snd_via8233_dxs_volume_control __devinitdata = {
+ .name = "VIA DXS Playback Volume",
+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ .info = snd_via8233_dxs_volume_info,
+ .get = snd_via8233_dxs_volume_get,
+ .put = snd_via8233_dxs_volume_put,
+};
+
/*
*/
ac97.clock = chip->ac97_clock;
if ((err = snd_ac97_mixer(chip->card, &ac97, &chip->ac97)) < 0)
return err;
+
+ if (chip->chip_type != TYPE_VIA686) {
+ /* use slot 10/11 */
+ snd_ac97_update_bits(chip->ac97, AC97_EXTENDED_STATUS, 0x03 << 4, 0x03 << 4);
+ }
+
return 0;
}
via82xx_t *chip = snd_kcontrol_chip(kcontrol);
u16 val;
- pci_read_config_word(chip->pci, 0x42, &val);
- ucontrol->value.integer.value[0] = (val & 0x08) ? 1 : 0;
+ pci_read_config_word(chip->pci, VIA_FUNC_ENABLE, &val);
+ ucontrol->value.integer.value[0] = (val & VIA_FUNC_ENABLE_GAME) ? 1 : 0;
return 0;
}
via82xx_t *chip = snd_kcontrol_chip(kcontrol);
u16 val, oval;
- pci_read_config_word(chip->pci, 0x42, &oval);
- val = oval & ~0x08;
+ pci_read_config_word(chip->pci, VIA_FUNC_ENABLE, &oval);
+ val = oval & ~VIA_FUNC_ENABLE_GAME;
if (ucontrol->value.integer.value[0])
- val |= 0x08;
+ val |= VIA_FUNC_ENABLE_GAME;
if (val != oval) {
- pci_write_config_word(chip->pci, 0x42, val);
+ pci_write_config_word(chip->pci, VIA_FUNC_ENABLE, val);
return 1;
}
return 0;
int i, err, caps;
unsigned char val;
- caps = chip->revision == VIA_REV_8233A ? 1 : 2;
+ caps = chip->chip_type == TYPE_VIA8233A ? 1 : 2;
for (i = 0; i < caps; i++) {
snd_via8233_capture_source.index = i;
err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_via8233_capture_source, chip));
return err;
}
err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_via8233_dxs3_spdif_control, chip));
+ if (err < 0)
+ return err;
+ err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_via8233_dxs_volume_control, chip));
if (err < 0)
return err;
/* select spdif data slot 10/11 */
- pci_read_config_byte(chip->pci, 0x49, &val);
- val &= ~0x03;
- pci_write_config_byte(chip->pci, 0x49, val);
+ pci_read_config_byte(chip->pci, VIA8233_SPDIF_CTRL, &val);
+ val = (val & ~VIA8233_SPDIF_SLOT_MASK) | VIA8233_SPDIF_SLOT_1011;
+ pci_write_config_byte(chip->pci, VIA8233_SPDIF_CTRL, val);
return 0;
}
legacy = chip->old_legacy;
legacy_cfg = chip->old_legacy_cfg;
- legacy |= 0x40; /* disable MIDI */
- legacy &= ~0x08; /* disable joystick */
- if (chip->revision >= 0x20) {
- if (check_region(pci_resource_start(chip->pci, 2), 4)) {
- rev_h = 0;
- legacy &= ~0x80; /* disable PCI I/O 2 */
- } else {
- rev_h = 1;
- legacy |= 0x80; /* enable PCI I/O 2 */
- }
+ legacy |= VIA_FUNC_MIDI_IRQMASK; /* FIXME: correct? (disable MIDI) */
+ legacy &= ~VIA_FUNC_ENABLE_GAME; /* disable joystick */
+ if (chip->revision >= VIA_REV_686_H) {
+ rev_h = 1;
+ if (check_region(pci_resource_start(chip->pci, 2), 4))
+ legacy &= ~VIA_FUNC_MIDI_PNP; /* disable PCI I/O 2 */
+ else
+ legacy |= VIA_FUNC_MIDI_PNP; /* enable PCI I/O 2 */
}
- pci_write_config_byte(chip->pci, 0x42, legacy);
- pci_write_config_byte(chip->pci, 0x43, legacy_cfg);
- if (rev_h && mpu_port[dev] >= 0x200) { /* force MIDI */
- legacy |= 0x02; /* enable MPU */
- pci_write_config_dword(chip->pci, 0x18, (mpu_port[dev] & 0xfffc) | 0x01);
- } else {
- if (rev_h && (legacy & 0x02)) {
+ pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, legacy);
+ pci_write_config_byte(chip->pci, VIA_PNP_CONTROL, legacy_cfg);
+ if (rev_h) {
+ if (mpu_port[dev] >= 0x200) { /* force MIDI */
+ pci_write_config_dword(chip->pci, 0x18, (mpu_port[dev] & 0xfffc) | 0x01);
+ } else if (legacy & VIA_FUNC_MIDI_PNP) {
mpu_port[dev] = pci_resource_start(chip->pci, 2);
if (mpu_port[dev] < 0x200) /* bad value */
- legacy &= ~0x02; /* disable MIDI */
- } else {
- switch (mpu_port[dev]) { /* force MIDI */
- case 0x300:
- case 0x310:
- case 0x320:
- case 0x330:
- legacy_cfg &= ~(3 << 2);
- legacy_cfg |= (mpu_port[dev] & 0x0030) >> 2;
- legacy |= 0x02;
- break;
- default: /* no, use BIOS settings */
- if (legacy & 0x02)
- mpu_port[dev] = 0x300 + ((legacy_cfg & 0x000c) << 2);
- }
+ legacy &= ~VIA_FUNC_ENABLE_MIDI; /* disable MIDI */
+ }
+ if (mpu_port[dev] >= 0x200)
+ legacy |= VIA_FUNC_ENABLE_MIDI;
+ else
+ legacy &= ~VIA_FUNC_ENABLE_MIDI;
+ } else {
+ switch (mpu_port[dev]) { /* force MIDI */
+ case 0x300:
+ case 0x310:
+ case 0x320:
+ case 0x330:
+ legacy_cfg &= ~(3 << 2);
+ legacy_cfg |= (mpu_port[dev] & 0x0030) >> 2;
+ legacy |= VIA_FUNC_ENABLE_MIDI;
+ break;
+ default: /* no, use BIOS settings */
+ if (legacy & VIA_FUNC_ENABLE_MIDI)
+ mpu_port[dev] = 0x300 + ((legacy_cfg & 0x000c) << 2);
+ break;
}
}
- pci_write_config_byte(chip->pci, 0x42, legacy);
- pci_write_config_byte(chip->pci, 0x43, legacy_cfg);
- if (legacy & 0x02) {
+ if (legacy & VIA_FUNC_ENABLE_MIDI) {
if (check_region(mpu_port[dev], 2)) {
printk(KERN_WARNING "unable to get MPU-401 port at 0x%lx, skipping\n", mpu_port[dev]);
- legacy &= ~0x02;
- pci_write_config_byte(chip->pci, 0x42, legacy);
- goto __skip_mpu;
- }
- if (snd_mpu401_uart_new(chip->card, 0, MPU401_HW_VIA686A,
- mpu_port[dev], 0,
- chip->irq, 0,
- &chip->rmidi) < 0) {
+ legacy &= ~VIA_FUNC_ENABLE_MIDI;
+ } else if (snd_mpu401_uart_new(chip->card, 0, MPU401_HW_VIA686A,
+ mpu_port[dev], 0,
+ chip->irq, 0,
+ &chip->rmidi) < 0) {
printk(KERN_WARNING "unable to initialize MPU-401 at 0x%lx, skipping\n", mpu_port[dev]);
- legacy &= ~0x02;
- pci_write_config_byte(chip->pci, 0x42, legacy);
- goto __skip_mpu;
+ legacy &= ~VIA_FUNC_ENABLE_MIDI;
}
- legacy &= ~0x40; /* enable MIDI interrupt */
- pci_write_config_byte(chip->pci, 0x42, legacy);
- __skip_mpu:
- ;
+ }
+ pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, legacy);
+ pci_write_config_byte(chip->pci, VIA_PNP_CONTROL, legacy_cfg);
+ if (legacy & VIA_FUNC_ENABLE_MIDI) {
+ legacy &= ~VIA_FUNC_MIDI_IRQMASK; /* enable MIDI interrupt */
+ pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, legacy);
}
/* card switches */
#if 0 /* broken on K7M? */
if (chip->chip_type == TYPE_VIA686)
/* disable all legacy ports */
- pci_write_config_byte(chip->pci, 0x42, 0);
+ pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, 0);
#endif
- pci_read_config_byte(chip->pci, 0x40, &pval);
- if (! (pval & 0x01)) { /* codec not ready? */
+ pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval);
+ if (! (pval & VIA_ACLINK_C00_READY)) { /* codec not ready? */
/* deassert ACLink reset, force SYNC */
- pci_write_config_byte(chip->pci, 0x41, 0xe0);
+ pci_write_config_byte(chip->pci, VIA_ACLINK_CTRL,
+ VIA_ACLINK_CTRL_ENABLE |
+ VIA_ACLINK_CTRL_RESET |
+ VIA_ACLINK_CTRL_SYNC);
+ udelay(100);
+#if 1 /* FIXME: should we do full reset here for all chip models? */
+ pci_write_config_byte(chip->pci, VIA_ACLINK_CTRL, 0x00);
udelay(100);
+#else
/* deassert ACLink reset, force SYNC (warm AC'97 reset) */
- pci_write_config_byte(chip->pci, 0x41, 0x60);
+ pci_write_config_byte(chip->pci, VIA_ACLINK_CTRL,
+ VIA_ACLINK_CTRL_RESET|VIA_ACLINK_CTRL_SYNC);
udelay(2);
- /* pci_write_config_byte(chip->pci, 0x41, 0x00);
- udelay(100);
- */
+#endif
/* ACLink on, deassert ACLink reset, VSR, SGD data out */
/* note - FM data out has trouble with non VRA codecs !! */
- pci_write_config_byte(chip->pci, 0x41, 0xcc);
+ pci_write_config_byte(chip->pci, VIA_ACLINK_CTRL, VIA_ACLINK_CTRL_INIT);
udelay(100);
}
/* Make sure VRA is enabled, in case we didn't do a
* complete codec reset, above */
- pci_read_config_byte(chip->pci, 0x41, &pval);
- if ((pval & 0xcc) != 0xcc) {
+ pci_read_config_byte(chip->pci, VIA_ACLINK_CTRL, &pval);
+ if ((pval & VIA_ACLINK_CTRL_INIT) != VIA_ACLINK_CTRL_INIT) {
/* ACLink on, deassert ACLink reset, VSR, SGD data out */
/* note - FM data out has trouble with non VRA codecs !! */
- pci_write_config_byte(chip->pci, 0x41, 0xcc);
+ pci_write_config_byte(chip->pci, VIA_ACLINK_CTRL, VIA_ACLINK_CTRL_INIT);
udelay(100);
}
/* wait until codec ready */
max_count = ((3 * HZ) / 4) + 1;
do {
- pci_read_config_byte(chip->pci, 0x40, &pval);
- if (pval & 0x01) /* primary codec ready */
+ pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval);
+ if (pval & VIA_ACLINK_C00_READY) /* primary codec ready */
break;
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(1);
if (chip->chip_type == TYPE_VIA686) {
/* route FM trap to IRQ, disable FM trap */
- pci_write_config_byte(chip->pci, 0x48, 0);
+ pci_write_config_byte(chip->pci, VIA_FM_NMI_CTRL, 0);
/* disable all GPI interrupts */
- outl(0, chip->port + 0x8c);
+ outl(0, VIAREG(chip, GPI_INTR));
}
return 0;
static int snd_via82xx_free(via82xx_t *chip)
{
- int i;
+ unsigned int i;
if (chip->irq < 0)
goto __end_hw;
if (chip->irq >= 0)
free_irq(chip->irq, (void *)chip);
if (chip->chip_type == TYPE_VIA686) {
- pci_write_config_byte(chip->pci, 0x42, chip->old_legacy);
- pci_write_config_byte(chip->pci, 0x43, chip->old_legacy_cfg);
+ pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, chip->old_legacy);
+ pci_write_config_byte(chip->pci, VIA_PNP_CONTROL, chip->old_legacy_cfg);
}
snd_magic_kfree(chip);
return 0;
static int __devinit snd_via82xx_create(snd_card_t * card,
struct pci_dev *pci,
int chip_type,
+ int revision,
unsigned int ac97_clock,
via82xx_t ** r_via)
{
return -ENOMEM;
chip->chip_type = chip_type;
+ chip->revision = revision;
spin_lock_init(&chip->reg_lock);
spin_lock_init(&chip->ac97_lock);
chip->pci = pci;
chip->irq = -1;
- pci_read_config_byte(pci, 0x42, &chip->old_legacy);
- pci_read_config_byte(pci, 0x43, &chip->old_legacy_cfg);
+ pci_read_config_byte(pci, VIA_FUNC_ENABLE, &chip->old_legacy);
+ pci_read_config_byte(pci, VIA_PNP_CONTROL, &chip->old_legacy_cfg);
chip->port = pci_resource_start(pci, 0);
if ((chip->res_port = request_region(chip->port, 256, card->driver)) == NULL) {
chip->irq = pci->irq;
if (ac97_clock >= 8000 && ac97_clock <= 48000)
chip->ac97_clock = ac97_clock;
- pci_read_config_byte(pci, PCI_REVISION_ID, &chip->revision);
synchronize_irq(chip->irq);
if ((err = snd_via82xx_chip_init(chip)) < 0) {
return 0;
}
+struct via823x_info {
+ int revision;
+ char *name;
+ int type;
+};
+static struct via823x_info via823x_cards[] __devinitdata = {
+ { VIA_REV_PRE_8233, "VIA 8233-Pre", TYPE_VIA8233 },
+ { VIA_REV_8233C, "VIA 8233C", TYPE_VIA8233 },
+ { VIA_REV_8233, "VIA 8233", TYPE_VIA8233 },
+ { VIA_REV_8233A, "VIA 8233A", TYPE_VIA8233A },
+ { VIA_REV_8235, "VIA 8235", TYPE_VIA8233 },
+};
+
static int __devinit snd_via82xx_probe(struct pci_dev *pci,
const struct pci_device_id *pci_id)
{
snd_card_t *card;
via82xx_t *chip;
unsigned char revision;
- int chip_type;
- int i, err;
+ int chip_type = 0, card_type;
+ unsigned int i;
+ int err;
if (dev >= SNDRV_CARDS)
return -ENODEV;
if (card == NULL)
return -ENOMEM;
- chip_type = pci_id->driver_data;
+ card_type = pci_id->driver_data;
pci_read_config_byte(pci, PCI_REVISION_ID, &revision);
- switch (chip_type) {
- case TYPE_VIA686:
+ switch (card_type) {
+ case TYPE_CARD_VIA686:
strcpy(card->driver, "VIA686A");
- strcpy(card->shortname, "VIA 82C686A/B");
+ sprintf(card->shortname, "VIA 82C686A/B rev%x", revision);
+ chip_type = TYPE_VIA686;
break;
- case TYPE_VIA8233:
- if (revision == VIA_REV_8233A) {
+ case TYPE_CARD_VIA8233:
+ chip_type = TYPE_VIA8233;
+ sprintf(card->shortname, "VIA 823x rev%x", revision);
+ for (i = 0; i < ARRAY_SIZE(via823x_cards); i++) {
+ if (revision == via823x_cards[i].revision) {
+ chip_type = via823x_cards[i].type;
+ strcpy(card->shortname, via823x_cards[i].name);
+ break;
+ }
+ }
+ if (chip_type == VIA_REV_8233A)
strcpy(card->driver, "VIA8233A");
- strcpy(card->shortname, "VIA 8233A");
- } else {
+ else
strcpy(card->driver, "VIA8233");
- strcpy(card->shortname, "VIA 8233/C");
- }
break;
default:
- snd_printk(KERN_ERR "invalid chip type %d\n", chip_type);
+ snd_printk(KERN_ERR "invalid card type %d\n", card_type);
err = -EINVAL;
goto __error;
}
- if ((err = snd_via82xx_create(card, pci, chip_type, ac97_clock[dev], &chip)) < 0)
+ if ((err = snd_via82xx_create(card, pci, chip_type, revision, ac97_clock[dev], &chip)) < 0)
goto __error;
if ((err = snd_via82xx_mixer_new(chip)) < 0)
(err = snd_via686_init_misc(chip, dev)) < 0)
goto __error;
} else {
- if (revision == VIA_REV_8233A) {
+ if (chip_type == VIA_REV_8233A) {
if ((err = snd_via8233a_pcm_new(chip)) < 0)
goto __error;
} else {
__setup("snd-via82xx=", alsa_card_via82xx_setup);
#endif /* ifndef MODULE */
-
// ymfpci_t *chip = snd_pcm_substream_chip(substream);
snd_pcm_runtime_t *runtime = substream->runtime;
ymfpci_pcm_t *ypcm = snd_magic_cast(ymfpci_pcm_t, runtime->private_data, return -ENXIO);
- int nvoice;
+ unsigned int nvoice;
ypcm->period_size = runtime->period_size;
ypcm->buffer_size = runtime->buffer_size;
{
ac97_t ac97;
snd_kcontrol_t *kctl;
- int err, idx;
+ unsigned int idx;
+ int err;
memset(&ac97, 0, sizeof(ac97));
ac97.write = snd_ymfpci_codec_write;
static int snd_ymfpci_joystick_addr_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
{
ymfpci_t *chip = snd_kcontrol_chip(kcontrol);
- ucontrol->value.integer.value[0] = chip->joystick_port;
+ ucontrol->value.enumerated.item[0] = chip->joystick_port;
return 0;
}
static int snd_ymfpci_joystick_addr_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
{
ymfpci_t *chip = snd_kcontrol_chip(kcontrol);
- if (ucontrol->value.integer.value[0] != chip->joystick_port) {
- snd_assert(ucontrol->value.integer.value[0] >= 0 && ucontrol->value.integer.value[0] < 4, return -EINVAL);
- chip->joystick_port = ucontrol->value.integer.value[0];
+ if (ucontrol->value.enumerated.item[0] != chip->joystick_port) {
+ snd_assert(ucontrol->value.enumerated.item[0] >= 0 && ucontrol->value.enumerated.item[0] < 4, return -EINVAL);
+ chip->joystick_port = ucontrol->value.enumerated.item[0];
setup_joystick_base(chip);
return 1;
}
void snd_ymfpci_suspend(ymfpci_t *chip)
{
snd_card_t *card = chip->card;
- int i;
+ unsigned int i;
if (card->power_state == SNDRV_CTL_POWER_D3hot)
return;
void snd_ymfpci_resume(ymfpci_t *chip)
{
snd_card_t *card = chip->card;
- int i;
+ unsigned int i;
if (card->power_state == SNDRV_CTL_POWER_D0)
return;
static int __init alsa_card_pmac_init(void)
{
int err;
- if ((err = snd_pmac_probe() < 0)) {
+ if ((err = snd_pmac_probe()) < 0) {
#ifdef MODULE
printk(KERN_ERR "no PMac soundchip found\n");
#endif
# <empty string> - CONFIG_SND_SEQUENCER is undefined
# otherwise parameter #1 value
#
-sequencer := $(if $(subst y,,$(CONFIG_SND_SEQUENCER)),m,$(if $(CONFIG_SND_SEQUENCER),$(1)))
+sequencer = $(if $(subst y,,$(CONFIG_SND_SEQUENCER)),$(if $(1),m),$(if $(CONFIG_SND_SEQUENCER),$(1)))
# Toplevel Module Dependencies
obj-$(call sequencer,$(CONFIG_SND_SBAWE)) += snd-emux-synth.o
SF_CLIENT_NO(p->chset.port));
else if (format == SNDRV_OSS_SOUNDFONT_PATCH) {
soundfont_patch_info_t patch;
- if (count < sizeof(patch))
+ if (count < (int)sizeof(patch))
rc = -EINVAL;
if (copy_from_user(&patch, buf, sizeof(patch)))
rc = -EFAULT;
}
p->chset.port = snd_seq_event_port_attach(emu->client, callback,
- cap, type, name);
+ cap, type, max_channels, name);
return p;
}
unsigned long flags;
int rc;
- if (count < sizeof(patch)) {
+ if (count < (long)sizeof(patch)) {
snd_printk("patch record too small %ld\n", count);
return -EINVAL;
}
soundfont_voice_map_t map;
/* get the link info */
- if (count < sizeof(map))
+ if (count < (int)sizeof(map))
return -EINVAL;
if (copy_from_user(&map, data, sizeof(map)))
return -EFAULT;
if (is_special_type(sf->type))
return -EINVAL;
- if (count < sizeof(hdr)) {
+ if (count < (long)sizeof(hdr)) {
printk("Soundfont error: invalid patch zone length\n");
return -EINVAL;
}
return -EINVAL;
}
- if (count < sizeof(soundfont_voice_info_t)*hdr.nvoices) {
+ if (count < (long)sizeof(soundfont_voice_info_t)*hdr.nvoices) {
printk("Soundfont Error: patch length(%ld) is smaller than nvoices(%d)\n",
count, hdr.nvoices);
return -EINVAL;
int note, sample_id;
int rc;
- if (count < sizeof(patch)) {
+ if (count < (long)sizeof(patch)) {
snd_printk("patch record too small %ld\n", count);
return -EINVAL;
}
struct audioformat {
struct list_head list;
snd_pcm_format_t format; /* format type */
- int channels; /* # channels */
+ unsigned int channels; /* # channels */
int iface; /* interface number */
unsigned char altsetting; /* corresponding alternate setting */
unsigned char altset_idx; /* array index of altenate setting */
unsigned char endpoint; /* endpoint */
unsigned char ep_attr; /* endpoint attributes */
unsigned int rates; /* rate bitmasks */
- int rate_min, rate_max; /* min/max rates */
- int nr_rates; /* number of rate table entries */
- int *rate_table; /* rate table */
+ unsigned int rate_min, rate_max; /* min/max rates */
+ unsigned int nr_rates; /* number of rate table entries */
+ unsigned int *rate_table; /* rate table */
};
struct snd_urb_ctx {
unsigned int running: 1; /* running status */
- int hwptr; /* free frame position in the buffer (only for playback) */
- int hwptr_done; /* processed frame position in the buffer */
- int transfer_sched; /* scheduled frames since last period (for playback) */
- int transfer_done; /* processed frames since last period update */
+ unsigned int hwptr; /* free frame position in the buffer (only for playback) */
+ unsigned int hwptr_done; /* processed frame position in the buffer */
+ unsigned int transfer_sched; /* scheduled frames since last period (for playback) */
+ unsigned int transfer_done; /* processed frames since last period update */
unsigned long active_mask; /* bitmask of active urbs */
unsigned long unlink_mask; /* bitmask of unlinked urbs */
- int nurbs; /* # urbs */
+ unsigned int nurbs; /* # urbs */
snd_urb_ctx_t dataurb[MAX_URBS]; /* data urb table */
snd_urb_ctx_t syncurb[SYNC_URBS]; /* sync urb table */
char syncbuf[SYNC_URBS * NRPACKS * 3]; /* sync buffer; it's so small - let's get static */
char *tmpbuf; /* temporary buffer for playback */
u64 formats; /* format bitmasks (all or'ed) */
- int num_formats; /* number of supported audio formats (list) */
+ unsigned int num_formats; /* number of supported audio formats (list) */
struct list_head fmt_list; /* format list */
spinlock_t lock;
{
unsigned long flags;
unsigned char *cp;
- int stride, i, len, oldptr;
+ int i;
+ unsigned int stride, len, oldptr;
stride = runtime->frame_bits >> 3;
spin_unlock_irqrestore(&subs->lock, flags);
/* copy a data chunk */
if (oldptr + len > runtime->buffer_size) {
- int cnt = runtime->buffer_size - oldptr;
- int blen = cnt * stride;
+ unsigned int cnt = runtime->buffer_size - oldptr;
+ unsigned int blen = cnt * stride;
memcpy(runtime->dma_area + oldptr * stride, cp, blen);
memcpy(runtime->dma_area, cp + blen, len * stride - blen);
} else {
snd_pcm_runtime_t *runtime,
struct urb *urb)
{
- unsigned int f, i, found;
+ int i;
+ unsigned int f, found;
unsigned char *cp = urb->transfer_buffer;
unsigned long flags;
struct urb *urb)
{
int i, stride, offs;
- int counts;
+ unsigned int counts;
unsigned long flags;
snd_urb_ctx_t *ctx = (snd_urb_ctx_t *)urb->context;
return;
if (! subs->running) /* can be stopped during retire callback */
return;
- if ((err = subs->ops.prepare(subs, substream->runtime, urb) < 0) ||
+ if ((err = subs->ops.prepare(subs, substream->runtime, urb)) < 0 ||
(err = usb_submit_urb(urb, GFP_ATOMIC)) < 0) {
snd_printd(KERN_ERR "cannot submit urb (err = %d)\n", err);
snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
*/
static int deactivate_urbs(snd_usb_substream_t *subs)
{
- int i, alive;
+ unsigned int i;
+ int alive;
subs->running = 0;
*/
static int start_urbs(snd_usb_substream_t *subs, snd_pcm_runtime_t *runtime)
{
- int i, err;
+ unsigned int i;
+ int err;
for (i = 0; i < subs->nurbs; i++) {
snd_assert(subs->dataurb[i].urb, return -EINVAL);
static int wait_clear_urbs(snd_usb_substream_t *subs)
{
int timeout = HZ;
- int i, alive;
+ unsigned int i;
+ int alive;
do {
alive = 0;
*/
static int init_substream_urbs(snd_usb_substream_t *subs, snd_pcm_runtime_t *runtime)
{
- int maxsize, n, i;
+ unsigned int maxsize, n, i;
int is_playback = subs->direction == SNDRV_PCM_STREAM_PLAYBACK;
- int npacks[MAX_URBS], total_packs;
+ unsigned int npacks[MAX_URBS], total_packs;
/* calculate the frequency in 10.14 format */
subs->freqn = subs->freqm = get_usb_rate(runtime->rate);
if (fp->rates & SNDRV_PCM_RATE_CONTINUOUS)
return fp;
else {
- int i;
+ unsigned int i;
for (i = 0; i < fp->nr_rates; i++)
if (fp->rate_table[i] == runtime->rate)
return fp;
return -EINVAL;
}
ep = get_endpoint(alts, 1)->bEndpointAddress;
- if ((is_playback && ep != (get_endpoint(alts, 0)->bSynchAddress | USB_DIR_IN)) ||
- (! is_playback && ep != (get_endpoint(alts, 0)->bSynchAddress & ~USB_DIR_IN))) {
+ if ((is_playback && ep != (unsigned int)(get_endpoint(alts, 0)->bSynchAddress | USB_DIR_IN)) ||
+ (! is_playback && ep != (unsigned int)(get_endpoint(alts, 0)->bSynchAddress & ~USB_DIR_IN))) {
snd_printk(KERN_ERR "%d:%d:%d : invalid synch pipe\n",
dev->devnum, fmt->iface, fmt->altsetting);
return -EINVAL;
snd_usb_substream_t *subs = rule->private;
struct list_head *p;
snd_interval_t *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
- int rmin, rmax, changed;
+ unsigned int rmin, rmax;
+ int changed;
hwc_debug("hw_rule_rate: (%d,%d)\n", it->min, it->max);
changed = 0;
snd_usb_substream_t *subs = rule->private;
struct list_head *p;
snd_interval_t *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
- int rmin, rmax, changed;
+ unsigned int rmin, rmax;
+ int changed;
hwc_debug("hw_rule_channels: (%d,%d)\n", it->min, it->max);
changed = 0;
snd_iprintf(buffer, " Rates: %d - %d (continous)\n",
fp->rate_min, fp->rate_max);
} else {
- int i;
+ unsigned int i;
snd_iprintf(buffer, " Rates: ");
for (i = 0; i < fp->nr_rates; i++) {
if (i > 0)
static void proc_dump_substream_status(snd_usb_substream_t *subs, snd_info_buffer_t *buffer)
{
if (subs->running) {
- int i;
+ unsigned int i;
snd_iprintf(buffer, " Status: Running\n");
snd_iprintf(buffer, " Interface = %d\n", subs->interface);
snd_iprintf(buffer, " Altset = %d\n", subs->format);
*/
int r, idx, c;
/* this table corresponds to the SNDRV_PCM_RATE_XXX bit */
- static int conv_rates[] = {
+ static unsigned int conv_rates[] = {
5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000,
64000, 88200, 96000, 176400, 192000
};
fp->nr_rates = nr_rates;
fp->rate_min = fp->rate_max = combine_triple(&fmt[8]);
for (r = 0, idx = 8; r < nr_rates; r++, idx += 3) {
- int rate = fp->rate_table[r] = combine_triple(&fmt[idx]);
+ unsigned int rate = fp->rate_table[r] = combine_triple(&fmt[idx]);
if (rate < fp->rate_min)
fp->rate_min = rate;
else if (rate > fp->rate_max)
snd_printk(KERN_ERR "%d:%u:%d: cannot create sequencer device\n", dev->devnum, ctrlif, j);
continue;
}
- usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1);
+ usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L);
continue;
}
if (altsd->bInterfaceClass != USB_CLASS_AUDIO ||
}
if (! parse_audio_endpoints(chip, buffer, buflen, j)) {
usb_set_interface(dev, j, 0); /* reset the current interface */
- usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1);
+ usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L);
}
}
if (err < 0)
return err;
if (quirk->ifnum != probed_ifnum)
- usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1);
+ usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L);
}
return 0;
}
snd_card_t *card;
struct list_head *p;
- if (ptr == (void *)-1)
+ if (ptr == (void *)-1L)
return;
chip = snd_magic_cast(snd_usb_audio_t, ptr, return);
ms_ep->bDescriptorType != USB_DT_CS_ENDPOINT ||
ms_ep->bDescriptorSubtype != MS_GENERAL)
continue;
- if ((ep->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK) == USB_DIR_OUT) {
+ if ((ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) {
if (endpoints[epidx].out_ep) {
if (++epidx >= MIDI_MAX_ENDPOINTS) {
printk(KERN_WARNING "snd-usb-midi: too many endpoints\n");
unsigned int ctl_mask, int control,
usb_audio_term_t *iterm, int unitid)
{
- int len = 0, mapped_name = 0;
+ unsigned int len = 0;
+ int mapped_name = 0;
int nameid = desc[desc[0] - 1];
snd_kcontrol_t *kctl;
usb_mixer_elem_info_t *cval;
int in_ch, int unitid)
{
usb_mixer_elem_info_t *cval;
- int num_ins = desc[4];
- int num_outs = desc[5 + num_ins];
- int i, len;
+ unsigned int num_ins = desc[4];
+ unsigned int num_outs = desc[5 + num_ins];
+ unsigned int i, len;
snd_kcontrol_t *kctl;
usb_audio_term_t iterm;
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
uinfo->count = 1;
uinfo->value.enumerated.items = cval->max;
- if (uinfo->value.enumerated.item >= cval->max)
+ if ((int)uinfo->value.enumerated.item >= cval->max)
uinfo->value.enumerated.item = cval->max - 1;
strcpy(uinfo->value.enumerated.name, itemlist[uinfo->value.enumerated.item]);
return 0;
*/
static int parse_audio_selector_unit(mixer_build_t *state, int unitid, unsigned char *desc)
{
- int num_ins = desc[4];
- int i, err, nameid, len;
+ unsigned int num_ins = desc[4];
+ unsigned int i, nameid, len;
+ int err;
usb_mixer_elem_info_t *cval;
snd_kcontrol_t *kctl;
char **namelist;
}
}
},
+{
+ USB_DEVICE(0x0582, 0x002d),
+ .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) {
+ .vendor_name = "Roland",
+ .product_name = "XV-2020",
+ .ifnum = 0,
+ .type = QUIRK_MIDI_FIXED_ENDPOINT,
+ .data = & (const snd_usb_midi_endpoint_info_t) {
+ .out_cables = 0x0001,
+ .in_cables = 0x0001
+ }
+ }
+},
{
USB_DEVICE(0x0582, 0x0033),
.driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) {