Commit a75af077 authored by Tomas Winkler's avatar Tomas Winkler Committed by Greg Kroah-Hartman

staging/easycap: add first level indentation to easycap_sound.c

Add the first level indentation to easycap_sound.c with astyle -t8.
41 lines over 80 characters were left out for further fix

Cc: Mike Thomas <rmthomas@sciolus.org>
Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent c7506658
...@@ -47,7 +47,8 @@ static const struct snd_pcm_hardware alsa_hardware = { ...@@ -47,7 +47,8 @@ static const struct snd_pcm_hardware alsa_hardware = {
.rate_max = 48000, .rate_max = 48000,
.channels_min = 2, .channels_min = 2,
.channels_max = 2, .channels_max = 2,
.buffer_bytes_max = PAGE_SIZE * PAGES_PER_AUDIO_FRAGMENT * .buffer_bytes_max = PAGE_SIZE *
PAGES_PER_AUDIO_FRAGMENT *
AUDIO_FRAGMENT_MANY, AUDIO_FRAGMENT_MANY,
.period_bytes_min = PAGE_SIZE * PAGES_PER_AUDIO_FRAGMENT, .period_bytes_min = PAGE_SIZE * PAGES_PER_AUDIO_FRAGMENT,
.period_bytes_max = PAGE_SIZE * PAGES_PER_AUDIO_FRAGMENT * 2, .period_bytes_max = PAGE_SIZE * PAGES_PER_AUDIO_FRAGMENT * 2,
...@@ -67,56 +68,56 @@ static const struct snd_pcm_hardware alsa_hardware = { ...@@ -67,56 +68,56 @@ static const struct snd_pcm_hardware alsa_hardware = {
void void
easycap_alsa_complete(struct urb *purb) easycap_alsa_complete(struct urb *purb)
{ {
struct easycap *peasycap; struct easycap *peasycap;
struct snd_pcm_substream *pss; struct snd_pcm_substream *pss;
struct snd_pcm_runtime *prt; struct snd_pcm_runtime *prt;
int dma_bytes, fragment_bytes; int dma_bytes, fragment_bytes;
int isfragment; int isfragment;
u8 *p1, *p2; u8 *p1, *p2;
s16 tmp; s16 tmp;
int i, j, more, much, rc; int i, j, more, much, rc;
#ifdef UPSAMPLE #ifdef UPSAMPLE
int k; int k;
s16 oldaudio, newaudio, delta; s16 oldaudio, newaudio, delta;
#endif /*UPSAMPLE*/ #endif /*UPSAMPLE*/
JOT(16, "\n"); JOT(16, "\n");
if (NULL == purb) { if (NULL == purb) {
SAY("ERROR: purb is NULL\n"); SAY("ERROR: purb is NULL\n");
return; return;
} }
peasycap = purb->context; peasycap = purb->context;
if (NULL == peasycap) { if (NULL == peasycap) {
SAY("ERROR: peasycap is NULL\n"); SAY("ERROR: peasycap is NULL\n");
return; return;
} }
if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
SAY("ERROR: bad peasycap\n"); SAY("ERROR: bad peasycap\n");
return; return;
} }
much = 0; much = 0;
if (peasycap->audio_idle) { if (peasycap->audio_idle) {
JOM(16, "%i=audio_idle %i=audio_isoc_streaming\n", JOM(16, "%i=audio_idle %i=audio_isoc_streaming\n",
peasycap->audio_idle, peasycap->audio_isoc_streaming); peasycap->audio_idle, peasycap->audio_isoc_streaming);
if (peasycap->audio_isoc_streaming) if (peasycap->audio_isoc_streaming)
goto resubmit; goto resubmit;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
pss = peasycap->psubstream; pss = peasycap->psubstream;
if (NULL == pss) if (NULL == pss)
goto resubmit; goto resubmit;
prt = pss->runtime; prt = pss->runtime;
if (NULL == prt) if (NULL == prt)
goto resubmit; goto resubmit;
dma_bytes = (int)prt->dma_bytes; dma_bytes = (int)prt->dma_bytes;
if (0 == dma_bytes) if (0 == dma_bytes)
goto resubmit; goto resubmit;
fragment_bytes = 4 * ((int)prt->period_size); fragment_bytes = 4 * ((int)prt->period_size);
if (0 == fragment_bytes) if (0 == fragment_bytes)
goto resubmit; goto resubmit;
/* -------------------------------------------------------------------------*/ /* -------------------------------------------------------------------------*/
if (purb->status) { if (purb->status) {
if ((-ESHUTDOWN == purb->status) || (-ENOENT == purb->status)) { if ((-ESHUTDOWN == purb->status) || (-ENOENT == purb->status)) {
JOM(16, "urb status -ESHUTDOWN or -ENOENT\n"); JOM(16, "urb status -ESHUTDOWN or -ENOENT\n");
return; return;
...@@ -124,7 +125,7 @@ if (purb->status) { ...@@ -124,7 +125,7 @@ if (purb->status) {
SAM("ERROR: non-zero urb status: -%s: %d\n", SAM("ERROR: non-zero urb status: -%s: %d\n",
strerror(purb->status), purb->status); strerror(purb->status), purb->status);
goto resubmit; goto resubmit;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* /*
* PROCEED HERE WHEN NO ERROR * PROCEED HERE WHEN NO ERROR
...@@ -132,10 +133,10 @@ if (purb->status) { ...@@ -132,10 +133,10 @@ if (purb->status) {
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#ifdef UPSAMPLE #ifdef UPSAMPLE
oldaudio = peasycap->oldaudio; oldaudio = peasycap->oldaudio;
#endif /*UPSAMPLE*/ #endif /*UPSAMPLE*/
for (i = 0; i < purb->number_of_packets; i++) { for (i = 0; i < purb->number_of_packets; i++) {
if (purb->iso_frame_desc[i].status < 0) { if (purb->iso_frame_desc[i].status < 0) {
SAM("-%s: %d\n", SAM("-%s: %d\n",
strerror(purb->iso_frame_desc[i].status), strerror(purb->iso_frame_desc[i].status),
...@@ -155,12 +156,12 @@ for (i = 0; i < purb->number_of_packets; i++) { ...@@ -155,12 +156,12 @@ for (i = 0; i < purb->number_of_packets; i++) {
p1 = (u8 *)(purb->transfer_buffer + p1 = (u8 *)(purb->transfer_buffer +
purb->iso_frame_desc[i].offset); purb->iso_frame_desc[i].offset);
/*---------------------------------------------------------------------------*/ /*
/* * COPY more BYTES FROM ISOC BUFFER
* COPY more BYTES FROM ISOC BUFFER TO THE DMA BUFFER, * TO THE DMA BUFFER, CONVERTING
* CONVERTING 8-BIT MONO TO 16-BIT SIGNED LITTLE-ENDIAN SAMPLES IF NECESSARY * 8-BIT MONO TO 16-BIT SIGNED
* LITTLE-ENDIAN SAMPLES IF NECESSARY
*/ */
/*---------------------------------------------------------------------------*/
while (more) { while (more) {
if (0 > more) { if (0 > more) {
SAM("MISTAKE: more is negative\n"); SAM("MISTAKE: more is negative\n");
...@@ -189,30 +190,24 @@ for (i = 0; i < purb->number_of_packets; i++) { ...@@ -189,30 +190,24 @@ for (i = 0; i < purb->number_of_packets; i++) {
if (much % 16) if (much % 16)
JOM(8, "MISTAKE? much" JOM(8, "MISTAKE? much"
" is not divisible by 16\n"); " is not divisible by 16\n");
if (much > (16 * if (much > (16 * more))
more))
much = 16 * much = 16 *
more; more;
p2 = (u8 *)(prt->dma_area + p2 = (u8 *)(prt->dma_area + peasycap->dma_fill);
peasycap->dma_fill);
for (j = 0; j < (much/16); j++) { for (j = 0; j < (much/16); j++) {
newaudio = ((int) *p1) - 128; newaudio = ((int) *p1) - 128;
newaudio = 128 * newaudio = 128 * newaudio;
newaudio;
delta = (newaudio - oldaudio) delta = (newaudio - oldaudio) / 4;
/ 4;
tmp = oldaudio + delta; tmp = oldaudio + delta;
for (k = 0; k < 4; k++) { for (k = 0; k < 4; k++) {
*p2 = (0x00FF & tmp); *p2 = (0x00FF & tmp);
*(p2 + 1) = (0xFF00 & *(p2 + 1) = (0xFF00 & tmp) >> 8;
tmp) >> 8;
p2 += 2; p2 += 2;
*p2 = (0x00FF & tmp); *p2 = (0x00FF & tmp);
*(p2 + 1) = (0xFF00 & *(p2 + 1) = (0xFF00 & tmp) >> 8;
tmp) >> 8;
p2 += 2; p2 += 2;
tmp += delta; tmp += delta;
} }
...@@ -223,37 +218,32 @@ for (i = 0; i < purb->number_of_packets; i++) { ...@@ -223,37 +218,32 @@ for (i = 0; i < purb->number_of_packets; i++) {
#else /*!UPSAMPLE*/ #else /*!UPSAMPLE*/
if (much > (2 * more)) if (much > (2 * more))
much = 2 * more; much = 2 * more;
p2 = (u8 *)(prt->dma_area + p2 = (u8 *)(prt->dma_area + peasycap->dma_fill);
peasycap->dma_fill);
for (j = 0; j < (much / 2); j++) { for (j = 0; j < (much / 2); j++) {
tmp = ((int) *p1) - 128; tmp = ((int) *p1) - 128;
tmp = 128 * tmp; tmp = 128 * tmp;
*p2 = (0x00FF & tmp); *p2 = (0x00FF & tmp);
*(p2 + 1) = (0xFF00 & tmp) >> *(p2 + 1) = (0xFF00 & tmp) >> 8;
8; p1++;
p1++; p2 += 2; p2 += 2;
more--; more--;
} }
#endif /*UPSAMPLE*/ #endif /*UPSAMPLE*/
} }
peasycap->dma_fill += much; peasycap->dma_fill += much;
if (peasycap->dma_fill >= peasycap->dma_next) { if (peasycap->dma_fill >= peasycap->dma_next) {
isfragment = peasycap->dma_fill / isfragment = peasycap->dma_fill / fragment_bytes;
fragment_bytes;
if (0 > isfragment) { if (0 > isfragment) {
SAM("MISTAKE: isfragment is " SAM("MISTAKE: isfragment is "
"negative\n"); "negative\n");
return; return;
} }
peasycap->dma_read = (isfragment peasycap->dma_read = (isfragment - 1) * fragment_bytes;
- 1) * fragment_bytes; peasycap->dma_next = (isfragment + 1) * fragment_bytes;
peasycap->dma_next = (isfragment if (dma_bytes < peasycap->dma_next)
+ 1) * fragment_bytes; peasycap->dma_next = fragment_bytes;
if (dma_bytes < peasycap->dma_next) {
peasycap->dma_next =
fragment_bytes;
}
if (0 <= peasycap->dma_read) { if (0 <= peasycap->dma_read) {
JOM(8, "snd_pcm_period_elap" JOM(8, "snd_pcm_period_elap"
"sed(), %i=" "sed(), %i="
...@@ -271,17 +261,17 @@ for (i = 0; i < purb->number_of_packets; i++) { ...@@ -271,17 +261,17 @@ for (i = 0; i < purb->number_of_packets; i++) {
} }
#ifdef UPSAMPLE #ifdef UPSAMPLE
peasycap->oldaudio = oldaudio; peasycap->oldaudio = oldaudio;
#endif /*UPSAMPLE*/ #endif /*UPSAMPLE*/
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* /*
* RESUBMIT THIS URB * RESUBMIT THIS URB
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
resubmit: resubmit:
if (peasycap->audio_isoc_streaming) { if (peasycap->audio_isoc_streaming) {
rc = usb_submit_urb(purb, GFP_ATOMIC); rc = usb_submit_urb(purb, GFP_ATOMIC);
if (rc) { if (rc) {
if ((-ENODEV != rc) && (-ENOENT != rc)) { if ((-ENODEV != rc) && (-ENOENT != rc)) {
...@@ -293,191 +283,192 @@ if (peasycap->audio_isoc_streaming) { ...@@ -293,191 +283,192 @@ if (peasycap->audio_isoc_streaming) {
if (0 < peasycap->audio_isoc_streaming) if (0 < peasycap->audio_isoc_streaming)
(peasycap->audio_isoc_streaming)--; (peasycap->audio_isoc_streaming)--;
} }
} }
return; return;
} }
/*****************************************************************************/ /*****************************************************************************/
static int easycap_alsa_open(struct snd_pcm_substream *pss) static int easycap_alsa_open(struct snd_pcm_substream *pss)
{ {
struct snd_pcm *psnd_pcm; struct snd_pcm *psnd_pcm;
struct snd_card *psnd_card; struct snd_card *psnd_card;
struct easycap *peasycap; struct easycap *peasycap;
JOT(4, "\n"); JOT(4, "\n");
if (NULL == pss) { if (NULL == pss) {
SAY("ERROR: pss is NULL\n"); SAY("ERROR: pss is NULL\n");
return -EFAULT; return -EFAULT;
} }
psnd_pcm = pss->pcm; psnd_pcm = pss->pcm;
if (NULL == psnd_pcm) { if (NULL == psnd_pcm) {
SAY("ERROR: psnd_pcm is NULL\n"); SAY("ERROR: psnd_pcm is NULL\n");
return -EFAULT; return -EFAULT;
} }
psnd_card = psnd_pcm->card; psnd_card = psnd_pcm->card;
if (NULL == psnd_card) { if (NULL == psnd_card) {
SAY("ERROR: psnd_card is NULL\n"); SAY("ERROR: psnd_card is NULL\n");
return -EFAULT; return -EFAULT;
} }
peasycap = psnd_card->private_data; peasycap = psnd_card->private_data;
if (NULL == peasycap) { if (NULL == peasycap) {
SAY("ERROR: peasycap is NULL\n"); SAY("ERROR: peasycap is NULL\n");
return -EFAULT; return -EFAULT;
} }
if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
SAY("ERROR: bad peasycap\n"); SAY("ERROR: bad peasycap\n");
return -EFAULT; return -EFAULT;
} }
if (peasycap->psnd_card != psnd_card) { if (peasycap->psnd_card != psnd_card) {
SAM("ERROR: bad peasycap->psnd_card\n"); SAM("ERROR: bad peasycap->psnd_card\n");
return -EFAULT; return -EFAULT;
} }
if (NULL != peasycap->psubstream) { if (NULL != peasycap->psubstream) {
SAM("ERROR: bad peasycap->psubstream\n"); SAM("ERROR: bad peasycap->psubstream\n");
return -EFAULT; return -EFAULT;
} }
pss->private_data = peasycap; pss->private_data = peasycap;
peasycap->psubstream = pss; peasycap->psubstream = pss;
pss->runtime->hw = peasycap->alsa_hardware; pss->runtime->hw = peasycap->alsa_hardware;
pss->runtime->private_data = peasycap; pss->runtime->private_data = peasycap;
pss->private_data = peasycap; pss->private_data = peasycap;
if (0 != easycap_sound_setup(peasycap)) { if (0 != easycap_sound_setup(peasycap)) {
JOM(4, "ending unsuccessfully\n"); JOM(4, "ending unsuccessfully\n");
return -EFAULT; return -EFAULT;
} }
JOM(4, "ending successfully\n"); JOM(4, "ending successfully\n");
return 0; return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
static int easycap_alsa_close(struct snd_pcm_substream *pss) static int easycap_alsa_close(struct snd_pcm_substream *pss)
{ {
struct easycap *peasycap; struct easycap *peasycap;
JOT(4, "\n"); JOT(4, "\n");
if (NULL == pss) { if (NULL == pss) {
SAY("ERROR: pss is NULL\n"); SAY("ERROR: pss is NULL\n");
return -EFAULT; return -EFAULT;
} }
peasycap = snd_pcm_substream_chip(pss); peasycap = snd_pcm_substream_chip(pss);
if (NULL == peasycap) { if (NULL == peasycap) {
SAY("ERROR: peasycap is NULL\n"); SAY("ERROR: peasycap is NULL\n");
return -EFAULT; return -EFAULT;
} }
if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
SAY("ERROR: bad peasycap\n"); SAY("ERROR: bad peasycap\n");
return -EFAULT; return -EFAULT;
} }
pss->private_data = NULL; pss->private_data = NULL;
peasycap->psubstream = NULL; peasycap->psubstream = NULL;
JOT(4, "ending successfully\n"); JOT(4, "ending successfully\n");
return 0; return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
static int easycap_alsa_vmalloc(struct snd_pcm_substream *pss, size_t sz) static int easycap_alsa_vmalloc(struct snd_pcm_substream *pss, size_t sz)
{ {
struct snd_pcm_runtime *prt; struct snd_pcm_runtime *prt;
JOT(4, "\n"); JOT(4, "\n");
if (NULL == pss) { if (NULL == pss) {
SAY("ERROR: pss is NULL\n"); SAY("ERROR: pss is NULL\n");
return -EFAULT; return -EFAULT;
} }
prt = pss->runtime; prt = pss->runtime;
if (NULL == prt) { if (NULL == prt) {
SAY("ERROR: substream.runtime is NULL\n"); SAY("ERROR: substream.runtime is NULL\n");
return -EFAULT; return -EFAULT;
} }
if (prt->dma_area) { if (prt->dma_area) {
if (prt->dma_bytes > sz) if (prt->dma_bytes > sz)
return 0; return 0;
vfree(prt->dma_area); vfree(prt->dma_area);
} }
prt->dma_area = vmalloc(sz); prt->dma_area = vmalloc(sz);
if (NULL == prt->dma_area) if (NULL == prt->dma_area)
return -ENOMEM; return -ENOMEM;
prt->dma_bytes = sz; prt->dma_bytes = sz;
return 0; return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
static int easycap_alsa_hw_params(struct snd_pcm_substream *pss, static int easycap_alsa_hw_params(struct snd_pcm_substream *pss,
struct snd_pcm_hw_params *phw) struct snd_pcm_hw_params *phw)
{ {
int rc; int rc;
JOT(4, "%i\n", (params_buffer_bytes(phw))); JOT(4, "%i\n", (params_buffer_bytes(phw)));
if (NULL == pss) { if (NULL == pss) {
SAY("ERROR: pss is NULL\n"); SAY("ERROR: pss is NULL\n");
return -EFAULT; return -EFAULT;
} }
rc = easycap_alsa_vmalloc(pss, params_buffer_bytes(phw)); rc = easycap_alsa_vmalloc(pss, params_buffer_bytes(phw));
if (rc) if (rc)
return rc; return rc;
return 0; return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
static int easycap_alsa_hw_free(struct snd_pcm_substream *pss) static int easycap_alsa_hw_free(struct snd_pcm_substream *pss)
{ {
struct snd_pcm_runtime *prt; struct snd_pcm_runtime *prt;
JOT(4, "\n"); JOT(4, "\n");
if (NULL == pss) { if (NULL == pss) {
SAY("ERROR: pss is NULL\n"); SAY("ERROR: pss is NULL\n");
return -EFAULT; return -EFAULT;
} }
prt = pss->runtime; prt = pss->runtime;
if (NULL == prt) { if (NULL == prt) {
SAY("ERROR: substream.runtime is NULL\n"); SAY("ERROR: substream.runtime is NULL\n");
return -EFAULT; return -EFAULT;
} }
if (NULL != prt->dma_area) { if (NULL != prt->dma_area) {
JOT(8, "prt->dma_area = %p\n", prt->dma_area); JOT(8, "prt->dma_area = %p\n", prt->dma_area);
vfree(prt->dma_area); vfree(prt->dma_area);
prt->dma_area = NULL; prt->dma_area = NULL;
} else } else
JOT(8, "dma_area already freed\n"); JOT(8, "dma_area already freed\n");
return 0; return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
static int easycap_alsa_prepare(struct snd_pcm_substream *pss) static int easycap_alsa_prepare(struct snd_pcm_substream *pss)
{ {
struct easycap *peasycap; struct easycap *peasycap;
struct snd_pcm_runtime *prt; struct snd_pcm_runtime *prt;
JOT(4, "\n"); JOT(4, "\n");
if (NULL == pss) { if (NULL == pss) {
SAY("ERROR: pss is NULL\n"); SAY("ERROR: pss is NULL\n");
return -EFAULT; return -EFAULT;
} }
prt = pss->runtime; prt = pss->runtime;
peasycap = snd_pcm_substream_chip(pss); peasycap = snd_pcm_substream_chip(pss);
if (NULL == peasycap) { if (NULL == peasycap) {
SAY("ERROR: peasycap is NULL\n"); SAY("ERROR: peasycap is NULL\n");
return -EFAULT; return -EFAULT;
} }
if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
SAY("ERROR: bad peasycap\n"); SAY("ERROR: bad peasycap\n");
return -EFAULT; return -EFAULT;
} }
JOM(16, "ALSA decides %8i Hz=rate\n", (int)pss->runtime->rate); JOM(16, "ALSA decides %8i Hz=rate\n", pss->runtime->rate);
JOM(16, "ALSA decides %8i =period_size\n", (int)pss->runtime->period_size); JOM(16, "ALSA decides %8ld =period_size\n", pss->runtime->period_size);
JOM(16, "ALSA decides %8i =periods\n", (int)pss->runtime->periods); JOM(16, "ALSA decides %8i =periods\n", pss->runtime->periods);
JOM(16, "ALSA decides %8i =buffer_size\n", (int)pss->runtime->buffer_size); JOM(16, "ALSA decides %8ld =buffer_size\n", pss->runtime->buffer_size);
JOM(16, "ALSA decides %8i =dma_bytes\n", (int)pss->runtime->dma_bytes); JOM(16, "ALSA decides %8zd =dma_bytes\n", pss->runtime->dma_bytes);
JOM(16, "ALSA decides %8i =boundary\n", (int)pss->runtime->boundary); JOM(16, "ALSA decides %8ld =boundary\n", pss->runtime->boundary);
JOM(16, "ALSA decides %8i =period_step\n", (int)pss->runtime->period_step); JOM(16, "ALSA decides %8i =period_step\n", pss->runtime->period_step);
JOM(16, "ALSA decides %8i =sample_bits\n", (int)pss->runtime->sample_bits); JOM(16, "ALSA decides %8i =sample_bits\n", pss->runtime->sample_bits);
JOM(16, "ALSA decides %8i =frame_bits\n", (int)pss->runtime->frame_bits); JOM(16, "ALSA decides %8i =frame_bits\n", pss->runtime->frame_bits);
JOM(16, "ALSA decides %8i =min_align\n", (int)pss->runtime->min_align); JOM(16, "ALSA decides %8ld =min_align\n", pss->runtime->min_align);
JOM(12, "ALSA decides %8i =hw_ptr_base\n", (int)pss->runtime->hw_ptr_base); JOM(12, "ALSA decides %8ld =hw_ptr_base\n", pss->runtime->hw_ptr_base);
JOM(12, "ALSA decides %8i =hw_ptr_interrupt\n", JOM(12, "ALSA decides %8ld =hw_ptr_interrupt\n",
(int)pss->runtime->hw_ptr_interrupt); pss->runtime->hw_ptr_interrupt);
if (prt->dma_bytes != 4 * ((int)prt->period_size) * ((int)prt->periods)) {
if (prt->dma_bytes != 4 * ((int)prt->period_size) * ((int)prt->periods)) {
SAY("MISTAKE: unexpected ALSA parameters\n"); SAY("MISTAKE: unexpected ALSA parameters\n");
return -ENOENT; return -ENOENT;
} }
return 0; return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
static int easycap_alsa_ack(struct snd_pcm_substream *pss) static int easycap_alsa_ack(struct snd_pcm_substream *pss)
...@@ -487,81 +478,81 @@ static int easycap_alsa_ack(struct snd_pcm_substream *pss) ...@@ -487,81 +478,81 @@ static int easycap_alsa_ack(struct snd_pcm_substream *pss)
/*****************************************************************************/ /*****************************************************************************/
static int easycap_alsa_trigger(struct snd_pcm_substream *pss, int cmd) static int easycap_alsa_trigger(struct snd_pcm_substream *pss, int cmd)
{ {
struct easycap *peasycap; struct easycap *peasycap;
int retval; int retval;
JOT(4, "%i=cmd cf %i=START %i=STOP\n", cmd, SNDRV_PCM_TRIGGER_START, JOT(4, "%i=cmd cf %i=START %i=STOP\n", cmd, SNDRV_PCM_TRIGGER_START,
SNDRV_PCM_TRIGGER_STOP); SNDRV_PCM_TRIGGER_STOP);
if (NULL == pss) { if (NULL == pss) {
SAY("ERROR: pss is NULL\n"); SAY("ERROR: pss is NULL\n");
return -EFAULT; return -EFAULT;
} }
peasycap = snd_pcm_substream_chip(pss); peasycap = snd_pcm_substream_chip(pss);
if (NULL == peasycap) { if (NULL == peasycap) {
SAY("ERROR: peasycap is NULL\n"); SAY("ERROR: peasycap is NULL\n");
return -EFAULT; return -EFAULT;
} }
if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
SAY("ERROR: bad peasycap\n"); SAY("ERROR: bad peasycap\n");
return -EFAULT; return -EFAULT;
} }
switch (cmd) { switch (cmd) {
case SNDRV_PCM_TRIGGER_START: { case SNDRV_PCM_TRIGGER_START: {
peasycap->audio_idle = 0; peasycap->audio_idle = 0;
break; break;
} }
case SNDRV_PCM_TRIGGER_STOP: { case SNDRV_PCM_TRIGGER_STOP: {
peasycap->audio_idle = 1; peasycap->audio_idle = 1;
break; break;
} }
default: default:
retval = -EINVAL; retval = -EINVAL;
} }
return 0; return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
static snd_pcm_uframes_t easycap_alsa_pointer(struct snd_pcm_substream *pss) static snd_pcm_uframes_t easycap_alsa_pointer(struct snd_pcm_substream *pss)
{ {
struct easycap *peasycap; struct easycap *peasycap;
snd_pcm_uframes_t offset; snd_pcm_uframes_t offset;
JOT(16, "\n"); JOT(16, "\n");
if (NULL == pss) { if (NULL == pss) {
SAY("ERROR: pss is NULL\n"); SAY("ERROR: pss is NULL\n");
return -EFAULT; return -EFAULT;
} }
peasycap = snd_pcm_substream_chip(pss); peasycap = snd_pcm_substream_chip(pss);
if (NULL == peasycap) { if (NULL == peasycap) {
SAY("ERROR: peasycap is NULL\n"); SAY("ERROR: peasycap is NULL\n");
return -EFAULT; return -EFAULT;
} }
if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
SAY("ERROR: bad peasycap\n"); SAY("ERROR: bad peasycap\n");
return -EFAULT; return -EFAULT;
} }
if ((0 != peasycap->audio_eof) || (0 != peasycap->audio_idle)) { if ((0 != peasycap->audio_eof) || (0 != peasycap->audio_idle)) {
JOM(8, "returning -EIO because " JOM(8, "returning -EIO because "
"%i=audio_idle %i=audio_eof\n", "%i=audio_idle %i=audio_eof\n",
peasycap->audio_idle, peasycap->audio_eof); peasycap->audio_idle, peasycap->audio_eof);
return -EIO; return -EIO;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
if (0 > peasycap->dma_read) { if (0 > peasycap->dma_read) {
JOM(8, "returning -EBUSY\n"); JOM(8, "returning -EBUSY\n");
return -EBUSY; return -EBUSY;
} }
offset = ((snd_pcm_uframes_t)peasycap->dma_read)/4; offset = ((snd_pcm_uframes_t)peasycap->dma_read)/4;
JOM(8, "ALSA decides %8i =hw_ptr_base\n", (int)pss->runtime->hw_ptr_base); JOM(8, "ALSA decides %8i =hw_ptr_base\n", (int)pss->runtime->hw_ptr_base);
JOM(8, "ALSA decides %8i =hw_ptr_interrupt\n", JOM(8, "ALSA decides %8i =hw_ptr_interrupt\n",
(int)pss->runtime->hw_ptr_interrupt); (int)pss->runtime->hw_ptr_interrupt);
JOM(8, "%7i=offset %7i=dma_read %7i=dma_next\n", JOM(8, "%7i=offset %7i=dma_read %7i=dma_next\n",
(int)offset, peasycap->dma_read, peasycap->dma_next); (int)offset, peasycap->dma_read, peasycap->dma_next);
return offset; return offset;
} }
/*****************************************************************************/ /*****************************************************************************/
static struct page *easycap_alsa_page(struct snd_pcm_substream *pss, static struct page *
unsigned long offset) easycap_alsa_page(struct snd_pcm_substream *pss, unsigned long offset)
{ {
return vmalloc_to_page(pss->runtime->dma_area + offset); return vmalloc_to_page(pss->runtime->dma_area + offset);
} }
...@@ -589,37 +580,36 @@ static struct snd_pcm_ops easycap_alsa_pcm_ops = { ...@@ -589,37 +580,36 @@ static struct snd_pcm_ops easycap_alsa_pcm_ops = {
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int easycap_alsa_probe(struct easycap *peasycap) int easycap_alsa_probe(struct easycap *peasycap)
{ {
int rc; int rc;
struct snd_card *psnd_card; struct snd_card *psnd_card;
struct snd_pcm *psnd_pcm; struct snd_pcm *psnd_pcm;
if (NULL == peasycap) { if (NULL == peasycap) {
SAY("ERROR: peasycap is NULL\n"); SAY("ERROR: peasycap is NULL\n");
return -ENODEV; return -ENODEV;
} }
if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
SAY("ERROR: bad peasycap\n"); SAY("ERROR: bad peasycap\n");
return -EFAULT; return -EFAULT;
} }
if (0 > peasycap->minor) { if (0 > peasycap->minor) {
SAY("ERROR: no minor\n"); SAY("ERROR: no minor\n");
return -ENODEV; return -ENODEV;
} }
peasycap->alsa_hardware = alsa_hardware; peasycap->alsa_hardware = alsa_hardware;
if (true == peasycap->microphone) { if (true == peasycap->microphone) {
peasycap->alsa_hardware.rates = SNDRV_PCM_RATE_32000; peasycap->alsa_hardware.rates = SNDRV_PCM_RATE_32000;
peasycap->alsa_hardware.rate_min = 32000; peasycap->alsa_hardware.rate_min = 32000;
peasycap->alsa_hardware.rate_max = 32000; peasycap->alsa_hardware.rate_max = 32000;
} else { } else {
peasycap->alsa_hardware.rates = SNDRV_PCM_RATE_48000; peasycap->alsa_hardware.rates = SNDRV_PCM_RATE_48000;
peasycap->alsa_hardware.rate_min = 48000; peasycap->alsa_hardware.rate_min = 48000;
peasycap->alsa_hardware.rate_max = 48000; peasycap->alsa_hardware.rate_max = 48000;
} }
if (0 != snd_card_create(SNDRV_DEFAULT_IDX1, "easycap_alsa", if (0 != snd_card_create(SNDRV_DEFAULT_IDX1, "easycap_alsa",
THIS_MODULE, 0, THIS_MODULE, 0, &psnd_card)) {
&psnd_card)) {
SAY("ERROR: Cannot do ALSA snd_card_create()\n"); SAY("ERROR: Cannot do ALSA snd_card_create()\n");
return -EFAULT; return -EFAULT;
} }
...@@ -657,7 +647,7 @@ if (true == peasycap->microphone) { ...@@ -657,7 +647,7 @@ if (true == peasycap->microphone) {
; ;
SAM("registered %s\n", &psnd_card->id[0]); SAM("registered %s\n", &psnd_card->id[0]);
} }
return 0; return 0;
} }
#endif /*! CONFIG_EASYCAP_OSS */ #endif /*! CONFIG_EASYCAP_OSS */
...@@ -675,50 +665,50 @@ return 0; ...@@ -675,50 +665,50 @@ return 0;
int int
easycap_sound_setup(struct easycap *peasycap) easycap_sound_setup(struct easycap *peasycap)
{ {
int rc; int rc;
JOM(4, "starting initialization\n"); JOM(4, "starting initialization\n");
if (NULL == peasycap) { if (NULL == peasycap) {
SAY("ERROR: peasycap is NULL.\n"); SAY("ERROR: peasycap is NULL.\n");
return -EFAULT; return -EFAULT;
} }
if (NULL == peasycap->pusb_device) { if (NULL == peasycap->pusb_device) {
SAM("ERROR: peasycap->pusb_device is NULL\n"); SAM("ERROR: peasycap->pusb_device is NULL\n");
return -ENODEV; return -ENODEV;
} }
JOM(16, "0x%08lX=peasycap->pusb_device\n", (long int)peasycap->pusb_device); JOM(16, "0x%08lX=peasycap->pusb_device\n", (long int)peasycap->pusb_device);
rc = audio_setup(peasycap); rc = audio_setup(peasycap);
JOM(8, "audio_setup() returned %i\n", rc); JOM(8, "audio_setup() returned %i\n", rc);
if (NULL == peasycap->pusb_device) { if (NULL == peasycap->pusb_device) {
SAM("ERROR: peasycap->pusb_device has become NULL\n"); SAM("ERROR: peasycap->pusb_device has become NULL\n");
return -ENODEV; return -ENODEV;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
if (NULL == peasycap->pusb_device) { if (NULL == peasycap->pusb_device) {
SAM("ERROR: peasycap->pusb_device has become NULL\n"); SAM("ERROR: peasycap->pusb_device has become NULL\n");
return -ENODEV; return -ENODEV;
} }
rc = usb_set_interface(peasycap->pusb_device, peasycap->audio_interface, rc = usb_set_interface(peasycap->pusb_device, peasycap->audio_interface,
peasycap->audio_altsetting_on); peasycap->audio_altsetting_on);
JOM(8, "usb_set_interface(.,%i,%i) returned %i\n", peasycap->audio_interface, JOM(8, "usb_set_interface(.,%i,%i) returned %i\n", peasycap->audio_interface,
peasycap->audio_altsetting_on, rc); peasycap->audio_altsetting_on, rc);
rc = wakeup_device(peasycap->pusb_device); rc = wakeup_device(peasycap->pusb_device);
JOM(8, "wakeup_device() returned %i\n", rc); JOM(8, "wakeup_device() returned %i\n", rc);
peasycap->audio_eof = 0; peasycap->audio_eof = 0;
peasycap->audio_idle = 0; peasycap->audio_idle = 0;
peasycap->timeval1.tv_sec = 0; peasycap->timeval1.tv_sec = 0;
peasycap->timeval1.tv_usec = 0; peasycap->timeval1.tv_usec = 0;
submit_audio_urbs(peasycap); submit_audio_urbs(peasycap);
JOM(4, "finished initialization\n"); JOM(4, "finished initialization\n");
return 0; return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
...@@ -729,25 +719,25 @@ return 0; ...@@ -729,25 +719,25 @@ return 0;
int int
submit_audio_urbs(struct easycap *peasycap) submit_audio_urbs(struct easycap *peasycap)
{ {
struct data_urb *pdata_urb; struct data_urb *pdata_urb;
struct urb *purb; struct urb *purb;
struct list_head *plist_head; struct list_head *plist_head;
int j, isbad, nospc, m, rc; int j, isbad, nospc, m, rc;
int isbuf; int isbuf;
if (NULL == peasycap) { if (NULL == peasycap) {
SAY("ERROR: peasycap is NULL\n"); SAY("ERROR: peasycap is NULL\n");
return -EFAULT; return -EFAULT;
} }
if (NULL == peasycap->purb_audio_head) { if (NULL == peasycap->purb_audio_head) {
SAM("ERROR: peasycap->urb_audio_head uninitialized\n"); SAM("ERROR: peasycap->urb_audio_head uninitialized\n");
return -EFAULT; return -EFAULT;
} }
if (NULL == peasycap->pusb_device) { if (NULL == peasycap->pusb_device) {
SAM("ERROR: peasycap->pusb_device is NULL\n"); SAM("ERROR: peasycap->pusb_device is NULL\n");
return -EFAULT; return -EFAULT;
} }
if (!peasycap->audio_isoc_streaming) { if (!peasycap->audio_isoc_streaming) {
JOM(4, "initial submission of all audio urbs\n"); JOM(4, "initial submission of all audio urbs\n");
rc = usb_set_interface(peasycap->pusb_device, rc = usb_set_interface(peasycap->pusb_device,
peasycap->audio_interface, peasycap->audio_interface,
...@@ -756,7 +746,9 @@ if (!peasycap->audio_isoc_streaming) { ...@@ -756,7 +746,9 @@ if (!peasycap->audio_isoc_streaming) {
peasycap->audio_interface, peasycap->audio_interface,
peasycap->audio_altsetting_on, rc); peasycap->audio_altsetting_on, rc);
isbad = 0; nospc = 0; m = 0; isbad = 0;
nospc = 0;
m = 0;
list_for_each(plist_head, (peasycap->purb_audio_head)) { list_for_each(plist_head, (peasycap->purb_audio_head)) {
pdata_urb = list_entry(plist_head, struct data_urb, list_head); pdata_urb = list_entry(plist_head, struct data_urb, list_head);
if (NULL != pdata_urb) { if (NULL != pdata_urb) {
...@@ -766,14 +758,11 @@ if (!peasycap->audio_isoc_streaming) { ...@@ -766,14 +758,11 @@ if (!peasycap->audio_isoc_streaming) {
purb->interval = 1; purb->interval = 1;
purb->dev = peasycap->pusb_device; purb->dev = peasycap->pusb_device;
purb->pipe = purb->pipe = usb_rcvisocpipe(peasycap->pusb_device,
usb_rcvisocpipe(peasycap->pusb_device,
peasycap->audio_endpointnumber); peasycap->audio_endpointnumber);
purb->transfer_flags = URB_ISO_ASAP; purb->transfer_flags = URB_ISO_ASAP;
purb->transfer_buffer = purb->transfer_buffer = peasycap->audio_isoc_buffer[isbuf].pgo;
peasycap->audio_isoc_buffer[isbuf].pgo; purb->transfer_buffer_length = peasycap->audio_isoc_buffer_size;
purb->transfer_buffer_length =
peasycap->audio_isoc_buffer_size;
#ifdef CONFIG_EASYCAP_OSS #ifdef CONFIG_EASYCAP_OSS
purb->complete = easyoss_complete; purb->complete = easyoss_complete;
#else /* CONFIG_EASYCAP_OSS */ #else /* CONFIG_EASYCAP_OSS */
...@@ -781,17 +770,10 @@ if (!peasycap->audio_isoc_streaming) { ...@@ -781,17 +770,10 @@ if (!peasycap->audio_isoc_streaming) {
#endif /* CONFIG_EASYCAP_OSS */ #endif /* CONFIG_EASYCAP_OSS */
purb->context = peasycap; purb->context = peasycap;
purb->start_frame = 0; purb->start_frame = 0;
purb->number_of_packets = purb->number_of_packets = peasycap->audio_isoc_framesperdesc;
peasycap->audio_isoc_framesperdesc; for (j = 0; j < peasycap->audio_isoc_framesperdesc; j++) {
for (j = 0; j < peasycap-> purb->iso_frame_desc[j].offset = j * peasycap->audio_isoc_maxframesize;
audio_isoc_framesperdesc; purb->iso_frame_desc[j].length = peasycap->audio_isoc_maxframesize;
j++) {
purb->iso_frame_desc[j].offset = j *
peasycap->
audio_isoc_maxframesize;
purb->iso_frame_desc[j].length =
peasycap->
audio_isoc_maxframesize;
} }
rc = usb_submit_urb(purb, GFP_KERNEL); rc = usb_submit_urb(purb, GFP_KERNEL);
...@@ -818,8 +800,7 @@ if (!peasycap->audio_isoc_streaming) { ...@@ -818,8 +800,7 @@ if (!peasycap->audio_isoc_streaming) {
if (isbad) { if (isbad) {
JOM(4, "attempting cleanup instead of submitting\n"); JOM(4, "attempting cleanup instead of submitting\n");
list_for_each(plist_head, (peasycap->purb_audio_head)) { list_for_each(plist_head, (peasycap->purb_audio_head)) {
pdata_urb = list_entry(plist_head, struct data_urb, pdata_urb = list_entry(plist_head, struct data_urb, list_head);
list_head);
if (NULL != pdata_urb) { if (NULL != pdata_urb) {
purb = pdata_urb->purb; purb = pdata_urb->purb;
if (NULL != purb) if (NULL != purb)
...@@ -831,10 +812,10 @@ if (!peasycap->audio_isoc_streaming) { ...@@ -831,10 +812,10 @@ if (!peasycap->audio_isoc_streaming) {
peasycap->audio_isoc_streaming = m; peasycap->audio_isoc_streaming = m;
JOM(4, "submitted %i audio urbs\n", m); JOM(4, "submitted %i audio urbs\n", m);
} }
} else } else
JOM(4, "already streaming audio urbs\n"); JOM(4, "already streaming audio urbs\n");
return 0; return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
...@@ -845,22 +826,21 @@ return 0; ...@@ -845,22 +826,21 @@ return 0;
int int
kill_audio_urbs(struct easycap *peasycap) kill_audio_urbs(struct easycap *peasycap)
{ {
int m; int m;
struct list_head *plist_head; struct list_head *plist_head;
struct data_urb *pdata_urb; struct data_urb *pdata_urb;
if (NULL == peasycap) { if (NULL == peasycap) {
SAY("ERROR: peasycap is NULL\n"); SAY("ERROR: peasycap is NULL\n");
return -EFAULT; return -EFAULT;
} }
if (peasycap->audio_isoc_streaming) { if (peasycap->audio_isoc_streaming) {
if (NULL != peasycap->purb_audio_head) { if (NULL != peasycap->purb_audio_head) {
peasycap->audio_isoc_streaming = 0; peasycap->audio_isoc_streaming = 0;
JOM(4, "killing audio urbs\n"); JOM(4, "killing audio urbs\n");
m = 0; m = 0;
list_for_each(plist_head, (peasycap->purb_audio_head)) { list_for_each(plist_head, (peasycap->purb_audio_head)) {
pdata_urb = list_entry(plist_head, struct data_urb, pdata_urb = list_entry(plist_head, struct data_urb, list_head);
list_head);
if (NULL != pdata_urb) { if (NULL != pdata_urb) {
if (NULL != pdata_urb->purb) { if (NULL != pdata_urb->purb) {
usb_kill_urb(pdata_urb->purb); usb_kill_urb(pdata_urb->purb);
...@@ -873,10 +853,10 @@ if (peasycap->audio_isoc_streaming) { ...@@ -873,10 +853,10 @@ if (peasycap->audio_isoc_streaming) {
SAM("ERROR: peasycap->purb_audio_head is NULL\n"); SAM("ERROR: peasycap->purb_audio_head is NULL\n");
return -EFAULT; return -EFAULT;
} }
} else { } else {
JOM(8, "%i=audio_isoc_streaming, no audio urbs killed\n", JOM(8, "%i=audio_isoc_streaming, no audio urbs killed\n",
peasycap->audio_isoc_streaming); peasycap->audio_isoc_streaming);
} }
return 0; return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
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