Changeset 356


Ignore:
Timestamp:
May 17, 2008, 9:49:53 AM (17 years ago)
Author:
Paul Smedley
Message:

test fix to see if reverting OSS32_SetHwParams to original Innotek version fixes HDA for all users

Location:
GPL/branches/uniaud32-2.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GPL/branches/uniaud32-2.0/lib32/sound.c

    r353 r356  
    1 /* $Id: sound.c,v 1.2 2003/08/08 15:09:03 vladest Exp $ */
    21/*
    32 * MMPM/2 to OSS interface translation layer
     
    4342#define samples_to_bytes(a)     ((a*pHandle->doublesamplesize)/2)
    4443#define bytes_to_samples(a)    (pHandle->doublesamplesize ? ((a*2)/pHandle->doublesamplesize) : a)
    45 
    4644int GetMaxChannels(ULONG deviceid, int type);
    4745
     
    771769    soundhandle        *pHandle = (soundhandle *)streamid;
    772770    struct snd_pcm_hw_params params;
    773     struct snd_pcm_status    status;
    774771    struct snd_pcm_sw_params swparams;
    775     int                 ret, ret1, nrperiods, minnrperiods, maxnrperiods, samplesize, i;
     772
     773    int                 ret, nrperiods, minnrperiods, maxnrperiods, samplesize;
    776774    ULONG               bufsize, periodsize, minperiodsize, maxperiodsize;
    777775    ULONG               periodbytes, minperiodbytes, maxperiodbytes;
    778776    BOOL                fTryAgain = FALSE;
    779     ULONG ulMinRate, ulMaxRate;
    780 
    781 #ifdef DEBUG
    782     dprintf(("OSS32_WaveSetHwParams"));
    783 #endif
     777
    784778    if(pHandle == NULL || pHandle->magic != MAGIC_WAVE_ALSA32) {
    785         printk("OSS32_WaveSetHwParams error. Invalid handle: %x\n", pHandle);
    786         DebugInt3();
    787         return OSSERR_INVALID_STREAMID;
     779          DebugInt3();
     780          return OSSERR_INVALID_STREAMID;
    788781    }
    789782    if(pHwParams == NULL) {
    790         printk("OSS32_WaveSetHwParams error. params = NULL\n");
    791         DebugInt3();
    792         return OSSERR_INVALID_PARAMETER;
     783          DebugInt3();
     784          return OSSERR_INVALID_PARAMETER;
    793785    }
    794786    if(pHwParams->ulDataType >= OSS32_PCM_MAX_FORMATS) {
    795         printk("OSS32_WaveSetHwParams error. Too high PCM format\n");
    796         DebugInt3();
    797         return OSSERR_INVALID_PARAMETER;
    798     }
    799     if ((int)pHwParams->ulNumChannels <= 0) {
    800         printk("OSS32_WaveSetHwParams error. Invalid number of channels: %i\n", pHwParams->ulNumChannels);
    801         DebugInt3();
    802         return OSSERR_INVALID_PARAMETER;
    803     }
    804 tryagain:
     787          DebugInt3();
     788          return OSSERR_INVALID_PARAMETER;
     789    }
     790
    805791    //set operation to non-blocking
    806792    pHandle->file.f_flags = O_NONBLOCK;
     793
    807794    //size of two samples (adpcm sample can be as small as 4 bits (mono), so take two)
    808795    samplesize = snd_pcm_format_size(OSSToALSADataType[pHwParams->ulDataType], 1);
     
    811798    periodbytes = pHwParams->ulPeriodSize;
    812799    periodsize  = bytes_to_samples(periodbytes);
    813     // checking number of channels
    814 
    815     printk("channels: %i, period bytes: %i\n",pHwParams->ulNumChannels, periodbytes);
    816     _snd_pcm_hw_params_any(&params);
    817     ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)__Stack32ToFlat(&params));
    818     ulMinRate     = hw_param_interval(&params, SNDRV_PCM_HW_PARAM_RATE)->min;
    819     ulMaxRate     = hw_param_interval(&params, SNDRV_PCM_HW_PARAM_RATE)->max;
    820 
    821     _snd_pcm_hw_params_any(&params);
    822     do {
    823         _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_ACCESS,
    824                               SNDRV_PCM_ACCESS_RW_INTERLEAVED, 0);
    825         _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_CHANNELS,
    826                               pHwParams->ulNumChannels, 0);
    827         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)__Stack32ToFlat(&params));
    828         if (ret == 0) break;
    829         pHwParams->ulNumChannels--;
    830     } while(ret < 0 && pHwParams->ulNumChannels > 1);
    831 
    832     printk("channels selected: %i\n",pHwParams->ulNumChannels);
    833800
    834801    //get all hardware parameters
     
    836803    _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_ACCESS,
    837804                          SNDRV_PCM_ACCESS_RW_INTERLEAVED, 0);
    838     _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_FORMAT,
    839                           OSSToALSADataType[pHwParams->ulDataType], 0);
    840     ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)__Stack32ToFlat(&params));
    841     if(ret != 0) {
    842         printk("invalid format %i\n", OSSToALSADataType[pHwParams->ulDataType]);
    843         return UNIXToOSSError(ret);
    844     }
    845     _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
    846                           pHwParams->ulBitsPerSample, 0);
    847     ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)__Stack32ToFlat(&params));
    848     if(ret != 0) {
    849         printk("invalid number of sample bits %i\n", pHwParams->ulBitsPerSample);
    850         return UNIXToOSSError(ret);
    851     }
    852     _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_FRAME_BITS,
    853                           pHwParams->ulBitsPerSample*pHwParams->ulNumChannels, 0);
    854     ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)__Stack32ToFlat(&params));
    855     if(ret != 0) {
    856         printk("invalid number of frame bits %i\n", pHwParams->ulBitsPerSample*pHwParams->ulNumChannels);
    857         return UNIXToOSSError(ret);
    858     }
    859 
    860805    _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
    861806                          pHwParams->ulBitsPerSample, 0);
     
    868813    _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_RATE,
    869814                          pHwParams->ulSampleRate, 0);
    870 
    871815    ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)__Stack32ToFlat(&params));
    872816    if(ret != 0) {
    873         printk("OSS32_WaveSetHwParams (first pass) error %i\n", ret);
    874         printk("bps: %i\n",pHwParams->ulBitsPerSample);
    875         printk("format: %i\n",OSSToALSADataType[pHwParams->ulDataType]);
    876         printk("channels: %i\n",pHwParams->ulNumChannels);
    877         printk("sample rate: %i\n",pHwParams->ulSampleRate);
    878 
    879 //        printk("OSS32_WaveSetHwParams invalid sample rate %i\n", pHwParams->ulSampleRate);
    880         //        printk("will set to nearest\n");
    881         _snd_pcm_hw_params_any(&params);
    882         for (i=0; i<(sizeof(rates)/sizeof(unsigned))-1;i++)
    883         {
    884             if (pHwParams->ulSampleRate >= rates[i] &&
    885                 pHwParams->ulSampleRate <= rates[i+1])
    886             {
    887                 pHwParams->ulSampleRate = rates[i];
    888                 _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_RATE,
    889                                       pHwParams->ulSampleRate, 0);
    890                 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)__Stack32ToFlat(&params));
    891                 if(ret == 0)
    892                 {
    893                     _snd_pcm_hw_params_any(&params);
    894                     _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
    895                                           pHwParams->ulBitsPerSample, 0);
    896                     _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_FRAME_BITS,
    897                                           pHwParams->ulBitsPerSample*pHwParams->ulNumChannels, 0);
    898                     _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_FORMAT,
    899                                           OSSToALSADataType[pHwParams->ulDataType], 0);
    900                     _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_CHANNELS,
    901                                           pHwParams->ulNumChannels, 0);
    902                     _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_RATE,
    903                                           pHwParams->ulSampleRate, 0);
    904                     ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)__Stack32ToFlat(&params));
    905                     goto __next;
    906                 }
    907             }
    908         }
    909 
    910 //        ret1 = pHandle->file.f_op->release(&pHandle->inode, &pHandle->file);
    911817        DebugInt3();
    912818        return UNIXToOSSError(ret);
    913819    }
    914 __next:
    915 
    916     printk("sample rate: %i\n",pHwParams->ulSampleRate);
    917820
    918821    //check period size against lower and upper boundaries
    919822    minperiodbytes = hw_param_interval((&params), SNDRV_PCM_HW_PARAM_PERIOD_BYTES)->min;
    920823    maxperiodbytes = hw_param_interval((&params), SNDRV_PCM_HW_PARAM_PERIOD_BYTES)->max;
    921 
    922824    if(periodbytes < minperiodbytes) {
    923825        periodbytes = minperiodbytes;
     
    927829        periodbytes = maxperiodbytes;
    928830    }
     831
    929832    minperiodsize = hw_param_interval((&params), SNDRV_PCM_HW_PARAM_PERIOD_SIZE)->min;
    930833    maxperiodsize = hw_param_interval((&params), SNDRV_PCM_HW_PARAM_PERIOD_SIZE)->max;
     
    936839        periodsize = maxperiodsize;
    937840    }
     841
    938842    if(samples_to_bytes(periodsize) < periodbytes) {
    939843        periodbytes = samples_to_bytes(periodsize);
     
    943847        periodsize = bytes_to_samples(periodbytes);
    944848    }
     849
    945850    //make sure period size is a whole fraction of the buffer size
    946851    bufsize = hw_param_interval((&params), SNDRV_PCM_HW_PARAM_BUFFER_BYTES)->max;
    947 
    948852    if(periodsize) {
    949853        nrperiods = bufsize/periodbytes;
    950854    }
    951855    else {
    952         printk("OSS32_WaveSetHwParams error. Invalid periodsize (=0). closing file\n");
    953 //        ret1 = pHandle->file.f_op->release(&pHandle->inode, &pHandle->file);
    954856        DebugInt3();
    955857        return OSSERR_INVALID_PARAMETER;
    956858    }
    957 
    958859    //check nr of periods against lower and upper boundaries
    959860    minnrperiods = hw_param_interval((&params), SNDRV_PCM_HW_PARAM_PERIODS)->min;
     
    970871    if(nrperiods == 1) {
    971872        DebugInt3();
    972         printk("OSS32_WaveSetHwParams error. Invalid number of periods(=1). closing file\n");
    973 //        ret1 = pHandle->file.f_op->release(&pHandle->inode, &pHandle->file);
    974873        return OSSERR_INVALID_PARAMETER;
    975874    }
     
    978877    //initialize parameter block & set sample rate, nr of channels and sample format, nr of periods,
    979878    //period size and buffer size
    980 //tryagain:
     879tryagain:
    981880    _snd_pcm_hw_params_any(&params);
    982881    _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_ACCESS,
     
    1003902                          periodbytes*nrperiods, 0);
    1004903
    1005 //#ifdef DEBUG_PK
    1006     printk("Hardware parameters: sample rate %i, data type %i, channels %i, period bytes %i, period size %i, nrperiods %i\n",
    1007              pHwParams->ulSampleRate, pHwParams->ulDataType, pHwParams->ulNumChannels, periodbytes, periodsize, nrperiods);
    1008 //#endif
     904    dprintf(("Hardware parameters: sample rate %d, data type %d, channels %d, period size %d, periods %d",
     905             pHwParams->ulSampleRate, pHwParams->ulDataType, pHwParams->ulNumChannels, periodsize, nrperiods));
     906
    1009907    ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_PARAMS, (ULONG)__Stack32ToFlat(&params));
    1010     printk("OSS32_WaveSetHwParams return %d after SNDRV_PCM_IOCTL_HW_PARAMS ioctl", ret);
    1011     if (ret == -77 && fTryAgain == FALSE)
    1012     {
    1013         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0);
    1014         fTryAgain = TRUE;
    1015         goto tryagain;
    1016     }
    1017908    if(ret) {
    1018909        if(fTryAgain == FALSE) {
     
    1027918            }
    1028919        }
    1029         printk("OSS32_WaveSetHwParams (second pass) error %i\n", ret);
    1030         printk("bps: %i\n",pHwParams->ulBitsPerSample);
    1031         printk("format: %i\n",OSSToALSADataType[pHwParams->ulDataType]);
    1032         printk("channels: %i\n",pHwParams->ulNumChannels);
    1033         printk("sample rate: %i\n",pHwParams->ulSampleRate);
    1034         printk("periodsize: %i\n",periodsize);
    1035         printk("periodbytes: %i\n",periodbytes);
    1036         printk("periods: %i\n",nrperiods);
    1037 //        ret1 = pHandle->file.f_op->release(&pHandle->inode, &pHandle->file);
    1038920        return UNIXToOSSError(ret);
    1039921    }
     
    1059941        ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_SW_PARAMS, (ULONG)__Stack32ToFlat(&swparams));
    1060942    }
    1061     total = 0;
    1062     per_bytes = periodbytes;
    1063     ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)__Stack32ToFlat(&status));
    1064     if ( ((status.state != SNDRV_PCM_STATE_PREPARED) &&
    1065           (status.state != SNDRV_PCM_STATE_SETUP) &&
    1066           (status.state != SNDRV_PCM_STATE_RUNNING) &&
    1067           (status.state != SNDRV_PCM_STATE_DRAINING))) {
    1068         printk("Device is not in proper state: %i. Calling prepare\n", status.state);
    1069         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0);
    1070     }
    1071     printk("OSS32_WaveSetHwParams return %d after SNDRV_PCM_IOCTL_SW_PARAMS ioctl, streamid %X", ret,(ULONG)pHandle);
    1072943    return UNIXToOSSError(ret);
    1073944}
  • GPL/branches/uniaud32-2.0/uniaud.inc

    r340 r356  
    77# BUILDVERSION must be 3 parts, and only numbers like 5.44.108
    88# It is best that 2'nd number is always 2 digits, eg at least 10
    9 BUILDVERSION = 1.9.3
     9BUILDVERSION = 1.9.4
    1010
    1111# Fixpack version
     
    1313# ex RC3  GA  FIXPACK2 beta_47
    1414# Comment out to avoid a fixpack line in bldlevel
    15 FIXPACK = SVN r340
     15FIXPACK = SVN r353
    1616
    1717# ALSA BUILD VERSION
Note: See TracChangeset for help on using the changeset viewer.