em28xx-audio: add debug info for the volume control
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/11 em28xx: Don't initialize a var if won't be using it
Fixes most cases of initializing a var but not using it.
There are still 3 cases at em28xx-alsa, were those vars should probably be used.
drivers/media/video/em28xx/em28xx-audio.c +5 -4
@@ -286,10 +286,9 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream) runtime->hw = snd_em28xx_hw_capture;if (dev->alt ==0 && dev->adev.users ==0 ) { -int errCode; dev->alt =7 ;dprintk ("changing alternate number to 7\n" ); - errCode =usb_set_interface (dev->udev,0 ,7 ); +usb_set_interface (dev->udev,0 ,7 ); } dev->adev.users++;
@@ -342,6 +341,8 @@ static int snd_em28xx_hw_capture_params(struct snd_pcm_substream *substream, ret =snd_pcm_alloc_vmalloc_buffer (substream,params_buffer_bytes (hw_params)); +if (ret <0 ) +return ret; format =params_format (hw_params); rate =params_rate (hw_params); channels =params_channels (hw_params);
@@ -393,7 +394,7 @@ static int snd_em28xx_capture_trigger(struct snd_pcm_substream *substream, int cmd) {struct em28xx *dev =snd_pcm_substream_chip (substream); -int retval; +int retval =0 ;switch (cmd) {case SNDRV_PCM_TRIGGER_START :
@@ -406,7 +407,7 @@ static int snd_em28xx_capture_trigger(struct snd_pcm_substream *substream, retval = -EINVAL ; }schedule_work (&dev->wq_trigger); -return 0 ; +return retval; } static snd_pcm_uframes_t snd_em28xx_capture_pointer(struct snd_pcm_substream
drivers/media/video/em28xx/em28xx-cards.c +1 -2
@@ -2660,10 +2660,9 @@ void em28xx_card_setup(struct em28xx *dev) .addr = 0xba >> 1, .platform_data = &pdata, }; -struct v4l2_subdev *sd; pdata.xtal = dev->sensor_xtal; - sd =v4l2_i2c_new_subdev_board (&dev->v4l2_dev, &dev->i2c_adap, +v4l2_i2c_new_subdev_board (&dev->v4l2_dev, &dev->i2c_adap, &mt9v011_info,NULL ); }
drivers/media/video/em28xx/em28xx-core.c +2 -2
@@ -917,7 +917,7 @@ EXPORT_SYMBOL_GPL(em28xx_set_mode);static void em28xx_irq_callback (struct urb *urb) {struct em28xx *dev = urb->context; -int rc, i; +int i;switch (urb->status) {case 0 :/* success */
@@ -934,7 +934,7 @@ static void em28xx_irq_callback(struct urb *urb)/* Copy data from URB */ spin_lock (&dev->slock); - rc = dev->isoc_ctl.isoc_copy (dev, urb); + dev->isoc_ctl.isoc_copy (dev, urb);spin_unlock (&dev->slock);/* Reset urb buffers */
drivers/media/video/em28xx/em28xx-i2c.c +0 -2
@@ -218,9 +218,7 @@ static int em28xx_i2c_recv_bytes(struct em28xx *dev, unsigned char addr,*/ static int em28xx_i2c_check_for_device (struct em28xx *dev,unsigned char addr) { -char msg;int ret; - msg = addr; ret = dev->em28xx_read_reg_req (dev,2 , addr);if (ret <0 ) {
Signature · 1 line
1.7.1
PATCH 2/11 em28xx: Fix a wrong enum at the ac97 control tables
In reply to a message not in the archivedrivers/media/video/em28xx/em28xx-core.c +8 -3
@@ -314,12 +314,12 @@ int em28xx_write_ac97(struct em28xx *dev, u8 reg, u16 val)return 0 ; } -struct em28xx_vol_table { +struct em28xx_vol_itable {enum em28xx_amux mux;u8 reg; }; -static struct em28xx_vol_table inputs[] = { +static struct em28xx_vol_itable inputs[] = { {EM28XX_AMUX_VIDEO ,AC97_VIDEO_VOL }, {EM28XX_AMUX_LINE_IN ,AC97_LINEIN_VOL }, {EM28XX_AMUX_PHONE ,AC97_PHONE_VOL },
@@ -403,7 +403,12 @@ static int em28xx_set_audio_source(struct em28xx *dev)return ret; } -static const struct em28xx_vol_table outputs[] = { +struct em28xx_vol_otable { +enum em28xx_aout mux; +u8 reg; +}; + +static const struct em28xx_vol_otable outputs[] = { {EM28XX_AOUT_MASTER ,AC97_MASTER_VOL }, {EM28XX_AOUT_LINE ,AC97_LINE_LEVEL_VOL }, {EM28XX_AOUT_MONO ,AC97_MASTER_MONO_VOL },
Signature · 1 line
1.7.1
PATCH 3/11 em28xx: Allow to compile it without RC/input support
In reply to a message not in the archivedrivers/media/video/em28xx/Kconfig +9 -1
@@ -3,7 +3,6 @@ config VIDEO_EM28XX depends on VIDEO_DEV && I2C select VIDEO_TUNER select VIDEO_TVEEPROM - depends on RC_CORE select VIDEOBUF_VMALLOC select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO select VIDEO_TVP5150 if VIDEO_HELPER_CHIPS_AUTO
@@ -44,3 +43,12 @@ config VIDEO_EM28XX_DVB ---help--- This adds support for DVB cards based on the Empiatech em28xx chips. + +config VIDEO_EM28XX_RC + bool "EM28XX Remote Controller support" + depends on RC_CORE + depends on VIDEO_EM28XX + depends on !(RC_CORE=m && VIDEO_EM28XX=y) + default y + ---help--- + Enables Remote Controller support on em28xx driver.
drivers/media/video/em28xx/Makefile +4 -2
@@ -1,5 +1,7 @@ -em28xx-objs := em28xx-video.o em28xx-i2c.o em28xx-cards.o em28xx-core.o \ - em28xx-input.o em28xx-vbi.o +em28xx-y := em28xx-video.o em28xx-i2c.o em28xx-cards.o +em28xx-y += em28xx-core.o em28xx-vbi.o + +em28xx-$(CONFIG_VIDEO_EM28XX_RC) += em28xx-input.o em28xx-alsa-objs := em28xx-audio.o
drivers/media/video/em28xx/em28xx.h +17 -0
@@ -697,6 +697,9 @@ int em28xx_tuner_callback(void *ptr, int component, int command, int arg);void em28xx_release_resources (struct em28xx *dev);/* Provided by em28xx-input.c */ + +#ifdef CONFIG_VIDEO_EM28XX_RC +int em28xx_get_key_terratec (struct IR_i2c *ir,u32 *ir_key,u32 *ir_raw);int em28xx_get_key_em_haup (struct IR_i2c *ir,u32 *ir_key,u32 *ir_raw); int em28xx_get_key_pinnacle_usb_grey(struct IR_i2c *ir, u32 *ir_key,
@@ -709,6 +712,20 @@ void em28xx_deregister_snapshot_button(struct em28xx *dev);int em28xx_ir_init (struct em28xx *dev);int em28xx_ir_fini (struct em28xx *dev); +#else + +#define em28xx_get_key_terratec NULL +#define em28xx_get_key_em_haup NULL +#define em28xx_get_key_pinnacle_usb_grey NULL +#define em28xx_get_key_winfast_usbii_deluxe NULL + +static inline void em28xx_register_snapshot_button (struct em28xx *dev) {} +static inline void em28xx_deregister_snapshot_button (struct em28xx *dev) {} +static inline int em28xx_ir_init (struct em28xx *dev) {return 0 ; } +static inline int em28xx_ir_fini (struct em28xx *dev) {return 0 ; } + +#endif +/* Provided by em28xx-vbi.c */ extern struct videobuf_queue_ops em28xx_vbi_qops;
Signature · 1 line
1.7.1
PATCH 4/11 em28xx-alsa: add mixer support for AC97 volume controls
In reply to a message not in the archiveExport ac97 volume controls via mixer.
Pulseaudio will probably handle it very badly, as it has no idea about how volumes are wired, and how are they associated with each TV input. Those wirings are card model dependent, and we don't have the wiring mappings for each supported device.
drivers/media/video/em28xx/em28xx-audio.c +103 -0
@@ -41,6 +41,7 @@#include <sound/info.h> #include <sound/initval.h> #include <sound/control.h> +#include <sound/tlv.h> #include <media/v4l2-common.h> #include "em28xx.h"
@@ -433,6 +434,92 @@ static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs,return vmalloc_to_page (pageptr); } +/* +* AC97 volume control support +*/ +static int em28xx_vol_info (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_info *info) +{ + info->type =SNDRV_CTL_ELEM_TYPE_INTEGER ; + info->count =2 ; + info->value.integer.min =0 ; + info->value.integer.max =0x1f ; + +return 0 ; +} + +/* FIXME: should also add mute controls for each */ + +static int em28xx_vol_put (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *value) +{ +struct em28xx *dev =snd_kcontrol_chip (kcontrol); +u16 val = (value->value.integer.value[0 ] &0x1f ) | + (value->value.integer.value[1 ] &0x1f ) <<8 ; +int rc; + +mutex_lock (&dev->lock); + rc =em28xx_read_ac97 (dev, kcontrol->private_value); +if (rc <0 ) + goto err; + + val |= rc &0x8080 ;/* Preserve the mute flags */ + + rc =em28xx_write_ac97 (dev, kcontrol->private_value, val); + +err: +mutex_unlock (&dev->lock); +return rc; +} + +static int em28xx_vol_get (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *value) +{ +struct em28xx *dev =snd_kcontrol_chip (kcontrol); +int val; + +mutex_lock (&dev->lock); + val =em28xx_read_ac97 (dev, kcontrol->private_value); +mutex_unlock (&dev->lock); +if (val <0 ) +return val; + + value->value.integer.value[0 ] = val &0x1f ; + value->value.integer.value[1 ] = (val <<8 ) &0x1f ; + +return 0 ; +} + +static const DECLARE_TLV_DB_SCALE(em28xx_db_scale, -3450, 150, 0); + +static int em28xx_cvol_new (struct snd_card *card,struct em28xx *dev, +char *name,int id) +{ +int err; +struct snd_kcontrol *kctl; +struct snd_kcontrol_new tmp = { + .iface =SNDRV_CTL_ELEM_IFACE_MIXER , + .name = name, + .info = em28xx_vol_info, + .get = em28xx_vol_get, + .put = em28xx_vol_put, + .private_value = id, + .tlv.p = em28xx_db_scale, + }; + + kctl =snd_ctl_new1 (&tmp, dev); + + err =snd_ctl_add (card, kctl); +if (err <0 ) +return err; + +return 0 ; +} + + +/* +* register/unregister code and data +*/ static struct snd_pcm_ops snd_em28xx_pcm_capture = { .open = snd_em28xx_capture_open, .close = snd_em28xx_pcm_close,
@@ -489,6 +576,22 @@ static int em28xx_audio_init(struct em28xx *dev)INIT_WORK (&dev->wq_trigger, audio_trigger); +if (dev->audio_mode.ac97 !=EM28XX_NO_AC97 ) { +em28xx_cvol_new (card, dev,"Video" ,AC97_VIDEO_VOL ); +em28xx_cvol_new (card, dev,"Line In" ,AC97_LINEIN_VOL ); +em28xx_cvol_new (card, dev,"Phone" ,AC97_PHONE_VOL ); +em28xx_cvol_new (card, dev,"Microphone" ,AC97_PHONE_VOL ); +em28xx_cvol_new (card, dev,"CD" ,AC97_CD_VOL ); +em28xx_cvol_new (card, dev,"AUX" ,AC97_AUX_VOL ); +em28xx_cvol_new (card, dev,"PCM" ,AC97_PCM_OUT_VOL ); + +em28xx_cvol_new (card, dev,"Master" ,AC97_MASTER_VOL ); +em28xx_cvol_new (card, dev,"Line" ,AC97_LINE_LEVEL_VOL ); +em28xx_cvol_new (card, dev,"Mono" ,AC97_MASTER_MONO_VOL ); +em28xx_cvol_new (card, dev,"LFE" ,AC97_LFE_MASTER_VOL ); +em28xx_cvol_new (card, dev,"Surround" ,AC97_SURR_MASTER_VOL ); + } + err =snd_card_register (card);if (err <0 ) {snd_card_free (card);
drivers/media/video/em28xx/em28xx-core.c +2 -0
@@ -286,6 +286,7 @@ int em28xx_read_ac97(struct em28xx *dev, u8 reg)return ret;return le16_to_cpu (val); } +EXPORT_SYMBOL_GPL (em28xx_read_ac97);/* * em28xx_write_ac97()
@@ -313,6 +314,7 @@ int em28xx_write_ac97(struct em28xx *dev, u8 reg, u16 val)return 0 ; } +EXPORT_SYMBOL_GPL (em28xx_write_ac97);struct em28xx_vol_itable {enum em28xx_amux mux;
Signature · 1 line
1.7.1
PATCH 5/11 em28xx-audio: add support for mute controls
In reply to a message not in the archivedrivers/media/video/em28xx/em28xx-audio.c +72 -13
@@ -448,8 +448,6 @@ static int em28xx_vol_info(struct snd_kcontrol *kcontrol,return 0 ; } -/* FIXME: should also add mute controls for each */ -static int em28xx_vol_put (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *value) {
@@ -463,7 +461,7 @@ static int em28xx_vol_put(struct snd_kcontrol *kcontrol,if (rc <0 ) goto err; - val |= rc &0x8080 ;/* Preserve the mute flags */ + val |= rc &0x8000 ;/* Preserve the mute flag */ rc =em28xx_write_ac97 (dev, kcontrol->private_value, val);
@@ -490,25 +488,87 @@ static int em28xx_vol_get(struct snd_kcontrol *kcontrol,return 0 ; } +static int em28xx_vol_put_mute (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *value) +{ +struct em28xx *dev =snd_kcontrol_chip (kcontrol); +u16 val = value->value.integer.value[0 ]; +int rc; + +mutex_lock (&dev->lock); + rc =em28xx_read_ac97 (dev, kcontrol->private_value); +if (rc <0 ) + goto err; + +if (val) + rc |=0x8000 ; +else + rc &=0x7f7f ; + + rc =em28xx_write_ac97 (dev, kcontrol->private_value, rc); + +err: +mutex_unlock (&dev->lock); +return rc; +} + +static int em28xx_vol_get_mute (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *value) +{ +struct em28xx *dev =snd_kcontrol_chip (kcontrol); +int val; + +mutex_lock (&dev->lock); + val =em28xx_read_ac97 (dev, kcontrol->private_value); +mutex_unlock (&dev->lock); +if (val <0 ) +return val; + +if (val &0x8000 ) + value->value.integer.value[0 ] =1 ; +else + value->value.integer.value[0 ] =0 ; + +return 0 ; +} + static const DECLARE_TLV_DB_SCALE(em28xx_db_scale, -3450, 150, 0);static int em28xx_cvol_new (struct snd_card *card,struct em28xx *dev,char *name,int id) {int err; +char ctl_name[44 ];struct snd_kcontrol *kctl; -struct snd_kcontrol_new tmp = { - .iface =SNDRV_CTL_ELEM_IFACE_MIXER , - .name = name, - .info = em28xx_vol_info, - .get = em28xx_vol_get, - .put = em28xx_vol_put, - .private_value = id, - .tlv.p = em28xx_db_scale, - }; +struct snd_kcontrol_new tmp; +memset (&tmp,0 ,sizeof (tmp)); + tmp.iface =SNDRV_CTL_ELEM_IFACE_MIXER , + tmp.private_value = id, + tmp.name = ctl_name, + +/* Add Mute Control */ +sprintf (ctl_name,"%s Switch" , name); + tmp.get = em28xx_vol_get_mute; + tmp.put = em28xx_vol_put_mute; + tmp.info = snd_ctl_boolean_mono_info; kctl =snd_ctl_new1 (&tmp, dev); + err =snd_ctl_add (card, kctl); +if (err <0 ) +return err; + +memset (&tmp,0 ,sizeof (tmp)); + tmp.iface =SNDRV_CTL_ELEM_IFACE_MIXER , + tmp.private_value = id, + tmp.name = ctl_name, +/* Add Volume Control */ +sprintf (ctl_name,"%s Volume" , name); + tmp.get = em28xx_vol_get; + tmp.put = em28xx_vol_put; + tmp.info = em28xx_vol_info; + tmp.tlv.p = em28xx_db_scale, + kctl =snd_ctl_new1 (&tmp, dev); err =snd_ctl_add (card, kctl);if (err <0 )return err;
@@ -516,7 +576,6 @@ static int em28xx_cvol_new(struct snd_card *card, struct em28xx *dev,return 0 ; } -/* * register/unregister code and data */
Signature · 1 line
1.7.1
PATCH 6/11 em28xx-audio: volumes are inverted
In reply to a message not in the archiveWhile here, fix volume mask to 5 bits
drivers/media/video/em28xx/em28xx-audio.c +8 -8
@@ -452,8 +452,8 @@ static int em28xx_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *value) {struct em28xx *dev =snd_kcontrol_chip (kcontrol); -u16 val = (value->value.integer.value[0 ] &0x1f ) | - (value->value.integer.value[1 ] &0x1f ) <<8 ; +u16 val = (0x1f - (value->value.integer.value[0 ] &0x1f )) | + (0x1f - (value->value.integer.value[1 ] &0x1f )) <<8 ;int rc;mutex_lock (&dev->lock);
@@ -482,8 +482,8 @@ static int em28xx_vol_get(struct snd_kcontrol *kcontrol,if (val <0 )return val; - value->value.integer.value[0 ] = val &0x1f ; - value->value.integer.value[1 ] = (val <<8 ) &0x1f ; + value->value.integer.value[0 ] =0x1f - (val &0x1f ); + value->value.integer.value[1 ] =0x1f - ((val <<8 ) &0x1f );return 0 ; }
@@ -501,9 +501,9 @@ static int em28xx_vol_put_mute(struct snd_kcontrol *kcontrol, goto err;if (val) + rc &=0x1f1f ; +else rc |=0x8000 ; -else - rc &=0x7f7f ; rc =em28xx_write_ac97 (dev, kcontrol->private_value, rc);
@@ -525,9 +525,9 @@ static int em28xx_vol_get_mute(struct snd_kcontrol *kcontrol,return val;if (val &0x8000 ) - value->value.integer.value[0 ] =1 ; -else value->value.integer.value[0 ] =0 ; +else + value->value.integer.value[0 ] =1 ;return 0 ; }
Signature · 1 line
1.7.1
PATCH 7/11 em28xx-audio: add debug info for the volume control
In reply to a message not in the archivedrivers/media/video/em28xx/em28xx-audio.c +28 -0
@@ -464,6 +464,13 @@ static int em28xx_vol_put(struct snd_kcontrol *kcontrol, val |= rc &0x8000 ;/* Preserve the mute flag */ rc =em28xx_write_ac97 (dev, kcontrol->private_value, val); +if (rc <0 ) + goto err; + +dprintk ("%sleft vol %d, right vol %d (0x%04x) to ac97 volume control 0x%04x\n" , + (val &0x8000 ) ?"muted " :"" , +0x1f - ((val >>8 ) &0x1f ),0x1f - (val &0x1f ), + val, (int )kcontrol->private_value); err:mutex_unlock (&dev->lock);
@@ -482,6 +489,11 @@ static int em28xx_vol_get(struct snd_kcontrol *kcontrol,if (val <0 )return val; +dprintk ("%sleft vol %d, right vol %d (0x%04x) from ac97 volume control 0x%04x\n" , + (val &0x8000 ) ?"muted " :"" , +0x1f - ((val >>8 ) &0x1f ),0x1f - (val &0x1f ), + val, (int )kcontrol->private_value); + value->value.integer.value[0 ] =0x1f - (val &0x1f ); value->value.integer.value[1 ] =0x1f - ((val <<8 ) &0x1f );
@@ -506,6 +518,13 @@ static int em28xx_vol_put_mute(struct snd_kcontrol *kcontrol, rc |=0x8000 ; rc =em28xx_write_ac97 (dev, kcontrol->private_value, rc); +if (rc <0 ) + goto err; + +dprintk ("%sleft vol %d, right vol %d (0x%04x) to ac97 volume control 0x%04x\n" , + (val &0x8000 ) ?"muted " :"" , +0x1f - ((val >>8 ) &0x1f ),0x1f - (val &0x1f ), + val, (int )kcontrol->private_value); err:mutex_unlock (&dev->lock);
@@ -529,6 +548,11 @@ static int em28xx_vol_get_mute(struct snd_kcontrol *kcontrol,else value->value.integer.value[0 ] =1 ; +dprintk ("%sleft vol %d, right vol %d (0x%04x) from ac97 volume control 0x%04x\n" , + (val &0x8000 ) ?"muted " :"" , +0x1f - ((val >>8 ) &0x1f ),0x1f - (val &0x1f ), + val, (int )kcontrol->private_value); +return 0 ; }
@@ -556,6 +580,8 @@ static int em28xx_cvol_new(struct snd_card *card, struct em28xx *dev, err =snd_ctl_add (card, kctl);if (err <0 )return err; +dprintk ("Added control %s for ac97 volume control 0x%04x\n" , + ctl_name, id);memset (&tmp,0 ,sizeof (tmp)); tmp.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -572,6 +598,8 @@ static int em28xx_cvol_new(struct snd_card *card, struct em28xx *dev, err =snd_ctl_add (card, kctl);if (err <0 )return err; +dprintk ("Added control %s for ac97 volume control 0x%04x\n" , + ctl_name, id);return 0 ; }
Signature · 1 line
1.7.1
PATCH 8/11 em28xx-audio: Properly report failures to start stream
In reply to a message not in the archiveIf the audio stream fails for any reason, it should:
1) Report an error via dmesg;
2) Mark internally that the stream didn't started.
drivers/media/video/em28xx/em28xx-audio.c +3 -0
@@ -213,9 +213,12 @@ static int em28xx_init_audio_isoc(struct em28xx *dev)for (i =0 ; i <EM28XX_AUDIO_BUFS ; i++) { errCode =usb_submit_urb (dev->adev.urb[i],GFP_ATOMIC );if (errCode) { +em28xx_errdev ("submit of audio urb failed\n" );em28xx_deinit_isoc_audio (dev); +atomic_set (&dev->stream_started,0 );return errCode; } + }return 0 ;
Signature · 1 line
1.7.1
PATCH 9/11 em28xx-audio: Some Alsa API fixes
In reply to a message not in the archiveMark the alsa stream with SNDRV_PCM_INFO_BATCH,
as the timing to get audio streams can vary.
Also, add SNDRV_PCM_TRIGGER for pause/release.
while here, fix the stop indicator, to be sure that audio will be properly released at the stop events.
drivers/media/video/em28xx/em28xx-audio.c +6 -1
@@ -249,6 +249,7 @@ static struct snd_pcm_hardware snd_em28xx_hw_capture = { .info = SNDRV_PCM_INFO_BLOCK_TRANSFER |SNDRV_PCM_INFO_MMAP |SNDRV_PCM_INFO_INTERLEAVED | +SNDRV_PCM_INFO_BATCH | SNDRV_PCM_INFO_MMAP_VALID, .formats = SNDRV_PCM_FMTBIT_S16_LE,
@@ -401,11 +402,15 @@ static int snd_em28xx_capture_trigger(struct snd_pcm_substream *substream,int retval =0 ;switch (cmd) { +case SNDRV_PCM_TRIGGER_PAUSE_RELEASE :/* fall through */ +case SNDRV_PCM_TRIGGER_RESUME :/* fall through */ case SNDRV_PCM_TRIGGER_START :atomic_set (&dev->stream_started,1 );break ; +case SNDRV_PCM_TRIGGER_PAUSE_PUSH :/* fall through */ +case SNDRV_PCM_TRIGGER_SUSPEND :/* fall through */ case SNDRV_PCM_TRIGGER_STOP : -atomic_set (&dev->stream_started,1 ); +atomic_set (&dev->stream_started,0 );break ;default : retval = -EINVAL ;
Signature · 1 line
1.7.1
PATCH 10/11 em28xx: Add support for devices with a separate audio interface
In reply to a message not in the archiveSome devices use a separate interface for the vendor audio class.
drivers/media/video/em28xx/em28xx-audio.c +25 -21
@@ -3,9 +3,9 @@* * Copyright (C) 2006 Markus Rechberger <[email protected]> * -* Copyright (C) 2007 Mauro Carvalho Chehab <[email protected]> +* Copyright (C) 2007-2011 Mauro Carvalho Chehab <[email protected]> * - Port to work with the in-kernel driver -* - Several cleanups +* - Cleanups, fixes, alsa-controls, etc. * * This driver is based on my previous au600 usb pstn audio driver * and inherits all the copyrights
@@ -281,24 +281,28 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)return -ENODEV ; } -/* Sets volume, mute, etc */ - - dev->mute =0 ; -mutex_lock (&dev->lock); - ret =em28xx_audio_analog_set (dev); -if (ret <0 ) - goto err; - runtime->hw = snd_em28xx_hw_capture; -if (dev->alt ==0 && dev->adev.users ==0 ) { - dev->alt =7 ; -dprintk ("changing alternate number to 7\n" ); -usb_set_interface (dev->udev,0 ,7 ); +if ((dev->alt ==0 || dev->audio_ifnum) && dev->adev.users ==0 ) { +if (dev->audio_ifnum) + dev->alt =1 ; +else + dev->alt =7 ; + +dprintk ("changing alternate number on interface %d to %d\n" , + dev->audio_ifnum, dev->alt); +usb_set_interface (dev->udev, dev->audio_ifnum, dev->alt); + +/* Sets volume, mute, etc */ + dev->mute =0 ; +mutex_lock (&dev->lock); + ret =em28xx_audio_analog_set (dev); +if (ret <0 ) + goto err; + + dev->adev.users++; +mutex_unlock (&dev->lock); } - dev->adev.users++; -mutex_unlock (&dev->lock); -snd_pcm_hw_constraint_integer (runtime,SNDRV_PCM_HW_PARAM_PERIODS ); dev->adev.capture_pcm_substream = substream; runtime->private_data = dev;
@@ -635,17 +639,17 @@ static int em28xx_audio_init(struct em28xx *dev)static int devnr;int err; -if (dev->has_alsa_audio !=1 ) { +if (!dev->has_alsa_audio || dev->audio_ifnum <0 ) {/* This device does not support the extension (in this case the device is expecting the snd-usb-audio module or doesn't have analog audio support at all) */ return 0 ; } -printk (KERN_INFO "em28xx-audio.c: probing for em28x1 " -"non standard usbaudio\n" ); +printk (KERN_INFO "em28xx-audio.c: probing for em28xx Audio Vendor Class\n" );printk (KERN_INFO "em28xx-audio.c: Copyright (C) 2006 Markus " "Rechberger\n" ); +printk (KERN_INFO "em28xx-audio.c: Copyright (C) 2007-2011 Mauro Carvalho Chehab\n" ); err =snd_card_create (index[devnr],"Em28xx Audio" ,THIS_MODULE ,0 , &card);
@@ -737,7 +741,7 @@ static void __exit em28xx_alsa_unregister(void)MODULE_LICENSE ("GPL" );MODULE_AUTHOR ("Markus Rechberger <[email protected]>" ); -MODULE_AUTHOR ("Mauro Carvalho Chehab <[email protected]>" ); +MODULE_AUTHOR ("Mauro Carvalho Chehab <[email protected]>" );MODULE_DESCRIPTION ("Em28xx Audio driver" );module_init (em28xx_alsa_register);
drivers/media/video/em28xx/em28xx-cards.c +73 -27
187 lines not on this page · raw message
drivers/media/video/em28xx/em28xx-core.c +8 -12
@@ -499,17 +499,13 @@ int em28xx_audio_setup(struct em28xx *dev)if (dev->chip_id ==CHIP_ID_EM2870 || dev->chip_id ==CHIP_ID_EM2874 || dev->chip_id ==CHIP_ID_EM28174 ) {/* Digital only device - don't load any alsa module */ - dev->audio_mode.has_audio =0 ; - dev->has_audio_class =0 ; - dev->has_alsa_audio =0 ; + dev->audio_mode.has_audio = false; + dev->has_audio_class = false; + dev->has_alsa_audio = false;return 0 ; } -/* If device doesn't support Usb Audio Class, use vendor class */ -if (!dev->has_audio_class) - dev->has_alsa_audio =1 ; - - dev->audio_mode.has_audio =1 ; + dev->audio_mode.has_audio = true;/* See how this device is configured */ cfg =em28xx_read_reg (dev,EM28XX_R00_CHIPCFG );
@@ -519,8 +515,8 @@ int em28xx_audio_setup(struct em28xx *dev) cfg =EM28XX_CHIPCFG_AC97 ;/* Be conservative */ }else if ((cfg &EM28XX_CHIPCFG_AUDIOMASK ) ==0x00 ) {/* The device doesn't have vendor audio at all */ - dev->has_alsa_audio =0 ; - dev->audio_mode.has_audio =0 ; + dev->has_alsa_audio = false; + dev->audio_mode.has_audio = false;return 0 ; }else if ((cfg &EM28XX_CHIPCFG_AUDIOMASK ) ==EM28XX_CHIPCFG_I2S_3_SAMPRATES ) {
@@ -549,8 +545,8 @@ int em28xx_audio_setup(struct em28xx *dev)*/ em28xx_warn ("AC97 chip type couldn't be determined\n" ); dev->audio_mode.ac97 =EM28XX_NO_AC97 ; - dev->has_alsa_audio =0 ; - dev->audio_mode.has_audio =0 ; + dev->has_alsa_audio = false; + dev->audio_mode.has_audio = false; goto init_audio; }
drivers/media/video/em28xx/em28xx.h +3 -0
@@ -487,6 +487,8 @@ struct em28xx {int devno;/* marks the number of this device */ enum em28xx_chip_id chip_id; +int audio_ifnum; +struct v4l2_device v4l2_dev;struct em28xx_board board;
@@ -503,6 +505,7 @@ struct em28xx { unsigned int has_audio_class:1; unsigned int has_alsa_audio:1; + unsigned int is_audio_only:1;/* Controls audio streaming */ struct work_struct wq_trigger;/* Trigger to start/stop audio for alsa module */
Signature · 1 line
1.7.1
PATCH 11/11 em28xx: Mark Kworld 305 as validated
In reply to a message not in the archiveThis board were used for testing the em28xx-alsa using a separate interface. So, it is obviously validated ;)
drivers/media/video/em28xx/em28xx-cards.c +0 -1
@@ -1319,7 +1319,6 @@ struct em28xx_board em28xx_boards[] = { }, [EM2880_BOARD_KWORLD_DVB_305U] = { .name = "KWorld DVB-T 305U", - .valid = EM28XX_BOARD_NOT_VALIDATED, .tuner_type = TUNER_XC2028, .tuner_gpio = default_tuner_gpio, .decoder = EM28XX_TVP5150,
Signature · 1 line
1.7.1