Commit a9855917 authored by Mike Thomas's avatar Mike Thomas Committed by Greg Kroah-Hartman

staging: easycap: add ALSA support

This is necessary because some distributions are disabling OSS entirely.
Signed-off-by: default avatarMike Thomas <rmthomas@sciolus.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent b54a28a4
config EASYCAP config EASYCAP
tristate "EasyCAP USB ID 05e1:0408 support" tristate "EasyCAP USB ID 05e1:0408 support"
depends on USB && VIDEO_DEV depends on USB && VIDEO_DEV && SND
---help--- ---help---
This is an integrated audio/video driver for EasyCAP cards with This is an integrated audio/video driver for EasyCAP cards with
......
easycap-objs := easycap_main.o easycap_low.o easycap_sound.o \
easycap_ioctl.o easycap_settings.o easycap_testcard.o
obj-$(CONFIG_EASYCAP) += easycap.o obj-$(CONFIG_EASYCAP) += easycap.o
easycap-y := easycap_main.o easycap_low.o easycap_sound.o
easycap-y += easycap_ioctl.o easycap_settings.o
easycap-y += easycap_testcard.o
ccflags-y := -Wall ccflags-y := -Wall
# Impose all or none of the following:
ccflags-y += -DEASYCAP_IS_VIDEODEV_CLIENT ccflags-y += -DEASYCAP_IS_VIDEODEV_CLIENT
ccflags-y += -DEASYCAP_NEEDS_V4L2_DEVICE_H ccflags-y += -DEASYCAP_NEEDS_V4L2_DEVICE_H
ccflags-y += -DEASYCAP_NEEDS_V4L2_FOPS ccflags-y += -DEASYCAP_NEEDS_V4L2_FOPS
ccflags-y += -DEASYCAP_NEEDS_UNLOCKED_IOCTL ccflags-y += -DEASYCAP_NEEDS_UNLOCKED_IOCTL
ccflags-y += -DEASYCAP_NEEDS_ALSA
ccflags-y += -DEASYCAP_NEEDS_CARD_CREATE
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
* EASYCAP_NEEDS_V4L2_DEVICE_H * EASYCAP_NEEDS_V4L2_DEVICE_H
* EASYCAP_NEEDS_V4L2_FOPS * EASYCAP_NEEDS_V4L2_FOPS
* EASYCAP_NEEDS_UNLOCKED_IOCTL * EASYCAP_NEEDS_UNLOCKED_IOCTL
* EASYCAP_NEEDS_ALSA
* EASYCAP_SILENT
* *
* IF REQUIRED THEY MUST BE EXTERNALLY DEFINED, FOR EXAMPLE AS COMPILER * IF REQUIRED THEY MUST BE EXTERNALLY DEFINED, FOR EXAMPLE AS COMPILER
* OPTIONS. * OPTIONS.
...@@ -57,9 +59,9 @@ ...@@ -57,9 +59,9 @@
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#undef EASYCAP_TESTCARD #undef EASYCAP_TESTCARD
#if (!defined(EASYCAP_NEEDS_ALSA))
#undef EASYCAP_TESTTONE #undef EASYCAP_TESTTONE
#undef NOREADBACK #endif /*EASYCAP_NEEDS_ALSA*/
#undef AUDIOTIME
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/errno.h> #include <linux/errno.h>
...@@ -79,6 +81,16 @@ ...@@ -79,6 +81,16 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/types.h> #include <linux/types.h>
#if defined(EASYCAP_NEEDS_ALSA)
#include <linux/vmalloc.h>
#include <linux/sound.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/info.h>
#include <sound/initval.h>
#include <sound/control.h>
#endif /*EASYCAP_NEEDS_ALSA*/
/*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
#if defined(EASYCAP_IS_VIDEODEV_CLIENT) #if defined(EASYCAP_IS_VIDEODEV_CLIENT)
#include <media/v4l2-dev.h> #include <media/v4l2-dev.h>
...@@ -112,7 +124,7 @@ ...@@ -112,7 +124,7 @@
#define USB_EASYCAP_VENDOR_ID 0x05e1 #define USB_EASYCAP_VENDOR_ID 0x05e1
#define USB_EASYCAP_PRODUCT_ID 0x0408 #define USB_EASYCAP_PRODUCT_ID 0x0408
#define EASYCAP_DRIVER_VERSION "0.8.41" #define EASYCAP_DRIVER_VERSION "0.9.01"
#define EASYCAP_DRIVER_DESCRIPTION "easycapdc60" #define EASYCAP_DRIVER_DESCRIPTION "easycapdc60"
#define USB_SKEL_MINOR_BASE 192 #define USB_SKEL_MINOR_BASE 192
...@@ -158,7 +170,8 @@ ...@@ -158,7 +170,8 @@
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#define AUDIO_ISOC_BUFFER_MANY 16 #define AUDIO_ISOC_BUFFER_MANY 16
#define AUDIO_ISOC_ORDER 3 #define AUDIO_ISOC_ORDER 1
#define AUDIO_ISOC_FRAMESPERDESC 32
#define AUDIO_ISOC_BUFFER_SIZE (PAGE_SIZE << AUDIO_ISOC_ORDER) #define AUDIO_ISOC_BUFFER_SIZE (PAGE_SIZE << AUDIO_ISOC_ORDER)
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* /*
...@@ -166,6 +179,7 @@ ...@@ -166,6 +179,7 @@
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#define AUDIO_FRAGMENT_MANY 32 #define AUDIO_FRAGMENT_MANY 32
#define PAGES_PER_AUDIO_FRAGMENT 4
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* /*
* IT IS ESSENTIAL THAT EVEN-NUMBERED STANDARDS ARE 25 FRAMES PER SECOND, * IT IS ESSENTIAL THAT EVEN-NUMBERED STANDARDS ARE 25 FRAMES PER SECOND,
...@@ -296,6 +310,7 @@ struct easycap { ...@@ -296,6 +310,7 @@ struct easycap {
#define TELLTALE "expectedstring" #define TELLTALE "expectedstring"
char telltale[16]; char telltale[16];
int isdongle; int isdongle;
int minor;
/*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ /*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
#if defined(EASYCAP_IS_VIDEODEV_CLIENT) #if defined(EASYCAP_IS_VIDEODEV_CLIENT)
...@@ -328,6 +343,7 @@ int done[FRAME_BUFFER_MANY]; ...@@ -328,6 +343,7 @@ int done[FRAME_BUFFER_MANY];
wait_queue_head_t wq_video; wait_queue_head_t wq_video;
wait_queue_head_t wq_audio; wait_queue_head_t wq_audio;
wait_queue_head_t wq_trigger;
int input; int input;
int polled; int polled;
...@@ -428,6 +444,20 @@ int allocation_video_page; ...@@ -428,6 +444,20 @@ int allocation_video_page;
int allocation_video_struct; int allocation_video_struct;
int registered_video; int registered_video;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/*
* ALSA
*/
/*---------------------------------------------------------------------------*/
#if defined(EASYCAP_NEEDS_ALSA)
struct snd_pcm_hardware alsa_hardware;
struct snd_card *psnd_card;
struct snd_pcm *psnd_pcm;
struct snd_pcm_substream *psubstream;
int dma_fill;
int dma_next;
int dma_read;
#endif /*EASYCAP_NEEDS_ALSA*/
/*---------------------------------------------------------------------------*/
/* /*
* SOUND PROPERTIES * SOUND PROPERTIES
*/ */
...@@ -455,10 +485,10 @@ struct list_head *purb_audio_head; ...@@ -455,10 +485,10 @@ struct list_head *purb_audio_head;
* BUFFER INDICATORS * BUFFER INDICATORS
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int audio_fill; /* Audio buffer being filled by easysnd_complete(). */ int audio_fill; /* Audio buffer being filled by easycap_complete(). */
/* Bumped only by easysnd_complete(). */ /* Bumped only by easycap_complete(). */
int audio_read; /* Audio buffer page being read by easysnd_read(). */ int audio_read; /* Audio buffer page being read by easycap_read(). */
/* Set by easysnd_read() to trail audio_fill by */ /* Set by easycap_read() to trail audio_fill by */
/* one fragment. */ /* one fragment. */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* /*
...@@ -532,19 +562,39 @@ int adjust_volume(struct easycap *, int); ...@@ -532,19 +562,39 @@ int adjust_volume(struct easycap *, int);
* AUDIO FUNCTION PROTOTYPES * AUDIO FUNCTION PROTOTYPES
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void easysnd_complete(struct urb *); #if defined(EASYCAP_NEEDS_ALSA)
ssize_t easysnd_read(struct file *, char __user *, size_t, loff_t *); int easycap_alsa_probe(struct easycap *);
int easysnd_open(struct inode *, struct file *);
int easysnd_release(struct inode *, struct file *); void easycap_alsa_complete(struct urb *);
long easysnd_ioctl_noinode(struct file *, unsigned int, \ int easycap_alsa_open(struct snd_pcm_substream *);
int easycap_alsa_close(struct snd_pcm_substream *);
int easycap_alsa_hw_params(struct snd_pcm_substream *, \
struct snd_pcm_hw_params *);
int easycap_alsa_vmalloc(struct snd_pcm_substream *, size_t);
int easycap_alsa_hw_free(struct snd_pcm_substream *);
int easycap_alsa_prepare(struct snd_pcm_substream *);
int easycap_alsa_ack(struct snd_pcm_substream *);
int easycap_alsa_trigger(struct snd_pcm_substream *, int);
snd_pcm_uframes_t \
easycap_alsa_pointer(struct snd_pcm_substream *);
struct page *easycap_alsa_page(struct snd_pcm_substream *, unsigned long);
#else
void easyoss_complete(struct urb *);
ssize_t easyoss_read(struct file *, char __user *, size_t, loff_t *);
int easyoss_open(struct inode *, struct file *);
int easyoss_release(struct inode *, struct file *);
long easyoss_ioctl_noinode(struct file *, unsigned int, \
unsigned long); unsigned long);
int easysnd_ioctl(struct inode *, struct file *, unsigned int, \ int easyoss_ioctl(struct inode *, struct file *, unsigned int, \
unsigned long); unsigned long);
unsigned int easysnd_poll(struct file *, poll_table *); unsigned int easyoss_poll(struct file *, poll_table *);
void easysnd_delete(struct kref *); void easyoss_delete(struct kref *);
#endif /*EASYCAP_NEEDS_ALSA*/
int easycap_sound_setup(struct easycap *);
int submit_audio_urbs(struct easycap *); int submit_audio_urbs(struct easycap *);
int kill_audio_urbs(struct easycap *); int kill_audio_urbs(struct easycap *);
void easysnd_testtone(struct easycap *, int); void easyoss_testtone(struct easycap *, int);
int audio_setup(struct easycap *); int audio_setup(struct easycap *);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* /*
......
This diff is collapsed.
...@@ -24,5 +24,14 @@ ...@@ -24,5 +24,14 @@
* *
*/ */
/*****************************************************************************/ /*****************************************************************************/
#if !defined(EASYCAP_IOCTL_H)
#define EASYCAP_IOCTL_H
extern int easycap_debug;
extern int easycap_gain;
extern struct easycap_dongle easycapdc60_dongle[];
extern struct easycap_standard easycap_standard[];
extern struct easycap_format easycap_format[]; extern struct easycap_format easycap_format[];
extern struct v4l2_queryctrl easycap_control[]; extern struct v4l2_queryctrl easycap_control[];
#endif /*EASYCAP_IOCTL_H*/
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
/****************************************************************************/ /****************************************************************************/
#include "easycap.h" #include "easycap.h"
#include "easycap_debug.h" #include "easycap_low.h"
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
const struct stk1160config { int reg; int set; } stk1160configPAL[256] = { const struct stk1160config { int reg; int set; } stk1160configPAL[256] = {
...@@ -1052,9 +1052,18 @@ rc = usb_control_msg(pusb_device, usb_sndctrlpipe(pusb_device, 0), \ ...@@ -1052,9 +1052,18 @@ rc = usb_control_msg(pusb_device, usb_sndctrlpipe(pusb_device, 0), \
(int)50000); (int)50000);
JOT(8, "0x%02X=buffer\n", *((__u8 *) &buffer[0])); JOT(8, "0x%02X=buffer\n", *((__u8 *) &buffer[0]));
if (rc != (int)length) if (rc != (int)length) {
SAY("ERROR: usb_control_msg returned %i\n", rc); switch (rc) {
case -EPIPE: {
SAY("usb_control_msg returned -EPIPE\n");
break;
}
default: {
SAY("ERROR: usb_control_msg returned %i\n", rc);
break;
}
}
}
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
/* /*
* REGISTER 500: SETTING VALUE TO 0x0094 RESETS AUDIO CONFIGURATION ??? * REGISTER 500: SETTING VALUE TO 0x0094 RESETS AUDIO CONFIGURATION ???
......
/***************************************************************************** /*****************************************************************************
* * * *
* easycap_debug.h * * easycap_low.h *
* * * *
*****************************************************************************/ *****************************************************************************/
/* /*
...@@ -24,6 +24,11 @@ ...@@ -24,6 +24,11 @@
* *
*/ */
/*****************************************************************************/ /*****************************************************************************/
#if !defined(EASYCAP_LOW_H)
#define EASYCAP_LOW_H
extern int easycap_debug; extern int easycap_debug;
extern int easycap_gain; extern int easycap_gain;
extern struct easycap_dongle easycap_dongle[]; extern struct easycap_dongle easycapdc60_dongle[];
#endif /*EASYCAP_LOW_H*/
This diff is collapsed.
/*****************************************************************************
* *
* easycap_main.h *
* *
*****************************************************************************/
/*
*
* Copyright (C) 2010 R.M. Thomas <rmthomas@sciolus.org>
*
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/*****************************************************************************/
#if !defined(EASYCAP_MAIN_H)
#define EASYCAP_MAIN_H
extern struct easycap_standard easycap_standard[];
extern struct easycap_format easycap_format[];
extern struct v4l2_queryctrl easycap_control[];
extern struct usb_driver easycap_usb_driver;
#if defined(EASYCAP_NEEDS_ALSA)
extern struct snd_pcm_ops easycap_alsa_ops;
extern struct snd_pcm_hardware easycap_pcm_hardware;
extern struct snd_card *psnd_card;
#else
extern struct usb_class_driver easyoss_class;
extern const struct file_operations easyoss_fops;
#endif /*EASYCAP_NEEDS_ALSA*/
#endif /*EASYCAP_MAIN_H*/
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
/*****************************************************************************/ /*****************************************************************************/
#include "easycap.h" #include "easycap.h"
#include "easycap_debug.h" #include "easycap_settings.h"
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* /*
......
/***************************************************************************** /*****************************************************************************
* * * *
* easycap_standard.h * * easycap_settings.h *
* * * *
*****************************************************************************/ *****************************************************************************/
/* /*
...@@ -24,4 +24,11 @@ ...@@ -24,4 +24,11 @@
* *
*/ */
/*****************************************************************************/ /*****************************************************************************/
extern struct easycap_standard easycap_standard[]; #if !defined(EASYCAP_SETTINGS_H)
#define EASYCAP_SETTINGS_H
extern int easycap_debug;
extern int easycap_gain;
extern struct easycap_dongle easycapdc60_dongle[];
#endif /*EASYCAP_SETTINGS_H*/
This diff is collapsed.
...@@ -24,5 +24,19 @@ ...@@ -24,5 +24,19 @@
* *
*/ */
/*****************************************************************************/ /*****************************************************************************/
#if !defined(EASYCAP_SOUND_H)
#define EASYCAP_SOUND_H
extern int easycap_debug;
extern int easycap_gain;
extern struct easycap_dongle easycapdc60_dongle[];
extern struct easycap *peasycap; extern struct easycap *peasycap;
extern struct usb_driver easycap_usb_driver; extern struct usb_driver easycap_usb_driver;
#if defined(EASYCAP_NEEDS_ALSA)
extern struct snd_pcm_hardware easycap_pcm_hardware;
#else
extern struct usb_class_driver easyoss_class;
extern const struct file_operations easyoss_fops;
#endif /*EASYCAP_NEEDS_ALSA*/
#endif /*EASYCAP_SOUND_H*/
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
/*****************************************************************************/ /*****************************************************************************/
#include "easycap.h" #include "easycap.h"
#include "easycap_debug.h" #include "easycap_testcard.h"
/*****************************************************************************/ /*****************************************************************************/
#define TESTCARD_BYTESPERLINE (2 * 720) #define TESTCARD_BYTESPERLINE (2 * 720)
...@@ -397,7 +397,7 @@ int tones[2048] = { ...@@ -397,7 +397,7 @@ int tones[2048] = {
}; };
/*****************************************************************************/ /*****************************************************************************/
void void
easysnd_testtone(struct easycap *peasycap, int audio_fill) easyoss_testtone(struct easycap *peasycap, int audio_fill)
{ {
int i1; int i1;
unsigned char *p2; unsigned char *p2;
......
/*****************************************************************************
* *
* easycap_testcard.h *
* *
*****************************************************************************/
/*
*
* Copyright (C) 2010 R.M. Thomas <rmthomas@sciolus.org>
*
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/*****************************************************************************/
#if !defined(EASYCAP_TESTCARD_H)
#define EASYCAP_TESTCARD_H
extern int easycap_debug;
extern int easycap_gain;
extern struct easycap_dongle easycapdc60_dongle[];
#endif /*EASYCAP_TESTCARD_H*/
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment