Changeset 679 for GPL/trunk/lib32


Ignore:
Timestamp:
Mar 18, 2021, 8:57:36 PM (5 years ago)
Author:
David Azarewicz
Message:

Merge changes from Paul's uniaud32next branch.

Location:
GPL/trunk
Files:
1 deleted
17 edited
20 copied

Legend:

Unmodified
Added
Removed
  • GPL/trunk

  • GPL/trunk/lib32/Makefile

    r604 r679  
    66!include $(ROOT)\tools\header.mif
    77
     8# note: Watcom headers must be before DDK headers to avoid conflicts
     9# with C runtime headers
     10%INCLUDE = $(%INCLUDE)$(DDK)\base\h;
    811AINCLUDES = $(DDK)\base\H
    912
     
    2124#
    2225#===================================================================
    23 FILES = spinlock.obj malloc.obj pci.obj irq.obj ioctl.obj &
     26FILES = spinlock.obj malloc.obj pci.obj irq.obj ioctl.obj devres.obj &
    2427  memory.obj debug.obj sound.obj soundmixer.obj soundmidi.obj &
    25   ossidc.obj semaphore.obj waitqueue.obj misc.obj &
    26   strncpy.obj task.obj &
    27   strncmp.obj timer.obj &
    28   instropl2.obj instropl3.obj vsprintf.obj
    29 # ossidc.obj semaphore.obj waitqueue.obj misc.obj fminstrload.obj
    30 !if $(KEE) == 0
    31 FILES += stack.obj
    32 !endif
     28  ossidc.obj semaphore.obj waitqueue.obj misc.obj klist.obj kasprintf.obj &
     29  seq_file.obj strncpy.obj strscpy.obj task.obj rbtree.obj &
     30  strncmp.obj timer.obj kobject.obj driver.obj drivers_base.obj &
     31  instropl2.obj instropl3.obj vsprintf.obj bitmap.obj find_next_bit.obj &
     32  regmap.obj regcache.obj regcache-flat.obj regcache-rbtree.obj
    3333
    3434TARGET = linuxlib
  • GPL/trunk/lib32/fminstrload.c

    r598 r679  
    215215    ev.data.ext.ptr = put;
    216216
    217     err = pHandle->file.f_op->write(&pHandle->file, (char *)__Stack32ToFlat(&ev), sizeof(ev), &pHandle->file.f_pos);
     217    err = pHandle->file.f_op->write(&pHandle->file, (char *)&ev, sizeof(ev), &pHandle->file.f_pos);
    218218    if(err < 0) {
    219219        dprintf(("Unable to write an instrument %.3i put event: %x",prg, err));
  • GPL/trunk/lib32/initcall.h

    r607 r679  
    3333extern_module_init(alsa_sound_init)
    3434extern_module_exit(alsa_sound_exit)
     35extern_module_init(alsa_seq_device_init)
     36extern_module_exit(alsa_seq_device_exit)
    3537extern_module_init(alsa_pcm_init)
    3638extern_module_exit(alsa_pcm_exit)
     
    4547extern_module_init(alsa_seq_init)
    4648extern_module_exit(alsa_seq_exit)
    47 extern_module_init(alsa_opl3_init)
    48 extern_module_exit(alsa_opl3_exit)
    49 extern_module_init(alsa_opl3_seq_init)
    50 extern_module_exit(alsa_opl3_seq_exit)
    51 extern_module_init(alsa_mpu401_uart_init)
    52 extern_module_exit(alsa_mpu401_uart_exit)
     49//extern_module_init(alsa_opl3_init)
     50//extern_module_exit(alsa_opl3_exit)
     51extern_module_init(opl3_seq_driver_init)
     52extern_module_exit(opl3_seq_driver_exit)
     53extern_module_init(regmap_initcall)
     54
     55//extern_module_init(alsa_mpu401_uart_init)
     56//extern_module_exit(alsa_mpu401_uart_exit)
    5357
    5458
    5559//pci cards
    56 extern_module_init(alsa_card_ali_init)
    57 extern_module_exit(alsa_card_ali_exit)
    58 extern_module_init(alsa_card_als4000_init)
    59 extern_module_exit(alsa_card_als4000_exit)
    60 extern_module_init(alsa_card_cs4281_init)
    61 extern_module_exit(alsa_card_cs4281_exit)
    62 extern_module_init(alsa_card_cs46xx_init)
    63 extern_module_exit(alsa_card_cs46xx_exit)
    64 extern_module_init(alsa_card_cs5535audio_init)
    65 extern_module_exit(alsa_card_cs5535audio_exit)
    66 extern_module_init(alsa_card_cmipci_init)
    67 extern_module_exit(alsa_card_cmipci_exit)
    68 extern_module_init(alsa_card_emu10k1_init)
    69 extern_module_exit(alsa_card_emu10k1_exit)
    70 extern_module_init(alsa_card_ens1370_init)
    71 extern_module_exit(alsa_card_ens1370_exit)
    72 extern_module_init(alsa_card_ens1371_init)
    73 extern_module_exit(alsa_card_ens1371_exit)
    74 extern_module_init(alsa_card_es1938_init)
    75 extern_module_exit(alsa_card_es1938_exit)
    76 extern_module_init(alsa_card_es1968_init)
    77 extern_module_exit(alsa_card_es1968_exit)
    78 extern_module_init(alsa_card_fm801_init)
    79 extern_module_exit(alsa_card_fm801_exit)
    80 extern_module_init(alsa_card_ice1712_init)
    81 extern_module_exit(alsa_card_ice1712_exit)
    82 extern_module_init(alsa_card_intel8x0_init)
    83 extern_module_exit(alsa_card_intel8x0_exit)
    84 extern_module_init(alsa_card_m3_init)
    85 extern_module_exit(alsa_card_m3_exit)
    86 extern_module_init(alsa_card_nm256_init)
    87 extern_module_exit(alsa_card_nm256_exit)
    88 extern_module_init(alsa_card_rme96_init)
    89 extern_module_exit(alsa_card_rme96_exit)
    90 extern_module_init(alsa_card_hammerfall_init)
    91 extern_module_exit(alsa_card_hammerfall_exit)
    92 extern_module_init(alsa_card_sonicvibes_init)
    93 extern_module_exit(alsa_card_sonicvibes_exit)
    94 extern_module_init(alsa_card_trident_init)
    95 extern_module_exit(alsa_card_trident_exit)
    96 extern_module_init(alsa_card_via82xx_init)
    97 extern_module_exit(alsa_card_via82xx_exit)
    98 extern_module_init(alsa_card_ymfpci_init)
    99 extern_module_exit(alsa_card_ymfpci_exit)
    100 extern_module_init(alsa_card_vortex_init)
    101 extern_module_exit(alsa_card_vortex_exit)
    102 extern_module_init(alsa_card_atiixp_init)
    103 extern_module_exit(alsa_card_atiixp_exit)
    104 extern_module_init(alsa_card_ca0106_init)
    105 extern_module_exit(alsa_card_ca0106_exit)
     60extern_module_init(ali5451_driver_init)
     61extern_module_exit(ali5451_driver_exit)
     62extern_module_init(als4000_driver_init)
     63extern_module_exit(als4000_driver_exit)
     64extern_module_init(cs4281_driver_init)
     65extern_module_exit(cs4281_driver_exit)
     66extern_module_init(cs46xx_driver_init)
     67extern_module_exit(cs46xx_driver_exit)
     68extern_module_init(cs5535audio_driver_init)
     69extern_module_exit(cs5535audio_driver_exit)
     70extern_module_init(cmipci_driver_init)
     71extern_module_exit(cmipci_driver_exit)
     72extern_module_init(emu10k1_driver_init)
     73extern_module_exit(emu10k1_driver_exit)
     74extern_module_init(ens137x_driver_init)
     75extern_module_exit(ens137x_driver_exit)
     76extern_module_init(es1938_driver_init)
     77extern_module_exit(es1938_driver_exit)
     78extern_module_init(es1968_driver_init)
     79extern_module_exit(es1968_driver_exit)
     80extern_module_init(fm801_driver_init)
     81extern_module_exit(fm801_driver_exit)
     82extern_module_init(ice1712_driver_init)
     83extern_module_exit(ice1712_driver_exit)
     84extern_module_init(intel8x0_driver_init)
     85extern_module_exit(intel8x0_driver_exit)
     86extern_module_init(m3_driver_init)
     87extern_module_exit(m3_driver_exit)
     88extern_module_init(nm256_driver_init)
     89extern_module_exit(nm256_driver_exit)
     90extern_module_init(rme96_driver_init)
     91extern_module_exit(rme96_driver_exit)
     92extern_module_init(hammerfall_driver_init)
     93extern_module_exit(hammerfall_driver_exit)
     94extern_module_init(sonicvibes_driver_init)
     95extern_module_exit(sonicvibes_driver_exit)
     96extern_module_init(trident_driver_init)
     97extern_module_exit(trident_driver_exit)
     98extern_module_init(via82xx_driver_init)
     99extern_module_exit(via82xx_driver_exit)
     100extern_module_init(ymfpci_driver_init)
     101extern_module_exit(ymfpci_driver_exit)
     102extern_module_init(vortex_driver_init)
     103extern_module_exit(vortex_driver_exit)
     104extern_module_init(atiixp_driver_init)
     105extern_module_exit(atiixp_driver_exit)
     106extern_module_init(ca0106_driver_init)
     107extern_module_exit(ca0106_driver_exit)
    106108extern_module_init(alsa_card_bt87x_init)
    107109extern_module_exit(alsa_card_bt87x_exit)
    108 extern_module_init(alsa_card_azx_init)
    109 extern_module_exit(alsa_card_azx_exit)
    110 extern_module_init(patch_analog_init)
    111 extern_module_exit(patch_analog_exit)
    112 extern_module_init(patch_cmedia_init)
    113 extern_module_exit(patch_cmedia_exit)
    114 extern_module_init(patch_conexant_init)
    115 extern_module_exit(patch_conexant_exit)
    116 extern_module_init(patch_realtek_init)
    117 extern_module_exit(patch_realtek_exit)
    118 extern_module_init(patch_sigmatel_init)
    119 extern_module_exit(patch_sigmatel_exit)
    120 extern_module_init(patch_via_init)
    121 extern_module_exit(patch_via_exit)
     110extern_module_init(ac97_bus_init)
     111
     112
     113
     114//hda
     115extern_module_init(hda_bus_init)
     116extern_module_exit(hda_bus_exit)
     117extern_module_init(generic_driver_init)
     118extern_module_exit(generic_driver_exit)
     119extern_module_init(azx_driver_init)
     120extern_module_exit(azx_driver_exit)
     121extern_module_init(analog_driver_init)
     122extern_module_exit(analog_driver_exit)
     123extern_module_init(cmedia_driver_init)
     124extern_module_exit(cmedia_driver_exit)
     125extern_module_init(ca0110_driver_init)
     126extern_module_exit(ca0110_driver_exit)
     127extern_module_init(cirrus_driver_init)
     128extern_module_exit(cirrus_driver_exit)
     129extern_module_init(conexant_driver_init)
     130extern_module_exit(conexant_driver_exit)
     131extern_module_init(hdmi_driver_init)
     132extern_module_exit(hdmi_driver_exit)
     133extern_module_init(realtek_driver_init)
     134extern_module_exit(realtek_driver_exit)
     135extern_module_init(sigmatel_driver_init)
     136extern_module_exit(sigmatel_driver_exit)
     137extern_module_init(via_driver_init)
     138extern_module_exit(via_driver_exit)
    122139
    123140
  • GPL/trunk/lib32/ioctl.c

    r598 r679  
    2121#include "soundoss.h"
    2222
     23#include <kee.h>
     24#include <u32ioctl.h>
     25
    2326POSS32_DEVCAPS pcmcaps[8] = {0,0,0,0,0,0,0,0};
    2427extern int pcm_device;
     
    3437int card_id_changed = 0;
    3538int unlock_all = 0;
    36 int GetUniaudPcmCaps(ULONG deviceid, void *caps);
    37 void FillCaps(ULONG deviceid);
    3839int pcm_instances(int card_id);
    3940
     
    6162{
    6263        int ctl_id;
    63         ULONG blkid = 0;
    6464        int i = 0;
    6565
     
    7777                        return -ETIME;
    7878
    79                 MyDevBlock(blkid, 1, 0);
     79                KernBlock((ULONG)&WaitForControlChange, 1, 0, 0, 0);
    8080                if (unlock_all)
    8181                {
     
    8989int WaitForPCMInterrupt(void *handle, int timeout)
    9090{
    91         ULONG blkid = 0;
    9291        int i = 0;
    9392        int j = 0;
     
    143142                }
    144143
    145                 MyDevBlock(blkid, 1, 0);
     144                KernBlock((ULONG)&WaitForPCMInterrupt, 1, 0, 0, 0);
    146145                if (unlock_all)
    147146                {
     
    180179}
    181180
     181/*
    182182int GetPcmForChannels(ULONG deviceid, int type, int channels)
    183183{
     
    220220        return sel_pcm;
    221221}
     222*/
    222223
    223224int GetMaxChannels(ULONG deviceid, int type)
     
    262263 returns pcm caps
    263264 */
    264 int GetUniaudPcmCaps1(ULONG deviceid, void *caps)
     265static int GetUniaudPcmCaps1(ULONG deviceid, void *caps)
    265266{
    266267        POSS32_DEVCAPS pcaps = (POSS32_DEVCAPS)caps;
     
    302303                        if(ret != OSSERR_SUCCESS)
    303304                        {
    304                                 dprintf(("GetUniaudPcmCaps: wave open error %i %s at pcm %i", ret, (j == 0) ?"PLAY":"REC", i));
     305                                dprintf(("GetUniaudPcmCaps1: wave open error %i %s at pcm %i", ret, (j == 0) ?"PLAY":"REC", i));
    305306                                continue;
    306307                                //goto fail;
     
    316317                        pHandle->file.f_flags = O_NONBLOCK;
    317318
    318                         dprintf(("GetUniaudPcmCaps: cp1. phandle %x", pHandle));
    319                         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_INFO, (ULONG)pcminfo);
     319                        dprintf(("GetUniaudPcmCaps: cp1. pcm %i, phandle %x", i, pHandle));
     320                        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_INFO, (ULONG)pcminfo);
    320321                        if(ret != 0) {
    321322                                rprintf(("GetUniaudPcmCaps: SNDRV_PCM_IOCTL_INFO error %i", ret));
     
    334335                        pWaveCaps->nrStreams = pcminfo->subdevices_count;
    335336
    336                         dprintf(("GetUniaudPcmCaps: cp2. nr of streams: %i", pWaveCaps->nrStreams));
     337                        dprintf(("GetUniaudPcmCaps: pcm %i, cp2. nr of streams: %i", i, pWaveCaps->nrStreams));
    337338                        //get all hardware parameters
    338339                        _snd_pcm_hw_params_any(params);
    339                         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)params);
     340                        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)params);
    340341                        if(ret != 0) {
    341342                                dprintf(("GetUniaudPcmCaps: SNDRV_PCM_IOCTL_HW_REFINE error %i", ret));
     
    362363                                pWaveCaps->ulChanFlags |= OSS32_CAPS_PCM_CHAN_5_1;
    363364                        }
    364 
    365365                        pWaveCaps->ulMinRate     = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE)->min;
    366366                        pWaveCaps->ulMaxRate     = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE)->max;
     
    469469        }
    470470        //retrieve mixer information
    471         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file,
     471        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file,
    472472                                                                        SNDRV_CTL_IOCTL_POWER_STATE,
    473473                                                                        (ULONG)state);
     
    523523        }
    524524        //retrieve mixer information
    525         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file,
     525        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file,
    526526                                                                        SNDRV_CTL_IOCTL_POWER,
    527527                                                                        (ULONG)state);
     
    579579        }
    580580        //retrieve mixer information
    581         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file,
     581        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file,
    582582                                                                        SNDRV_CTL_IOCTL_CARD_INFO,
    583583                                                                        (ULONG)(struct snd_ctl_card_info *)info);
     
    636636        }
    637637        //retrieve mixer information
    638         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file,
     638        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file,
    639639                                                                        SNDRV_CTL_IOCTL_CARD_INFO,
    640640                                                                        (ULONG)&pHandle->info);
     
    646646        pHandle->list.offset = 0;
    647647        pHandle->list.space  = 0;
    648         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file,
     648        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file,
    649649                                                                        SNDRV_CTL_IOCTL_ELEM_LIST,
    650650                                                                        (ULONG)&pHandle->list);
     
    704704        }
    705705        //retrieve mixer information
    706         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file,
     706        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file,
    707707                                                                        SNDRV_CTL_IOCTL_CARD_INFO,
    708708                                                                        (ULONG)&pHandle->info);
     
    714714        pHandle->list.offset = 0;
    715715        pHandle->list.space  = 0;
    716         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file,
     716        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file,
    717717                                                                        SNDRV_CTL_IOCTL_ELEM_LIST,
    718718                                                                        (ULONG)&pHandle->list);
     
    733733        pHandle->list.space  = pHandle->list.count;
    734734        pHandle->list.pids       = pHandle->pids;
    735         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file,
     735        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file,
    736736                                                                        SNDRV_CTL_IOCTL_ELEM_LIST,
    737737                                                                        (ULONG)&pHandle->list);
     
    807807
    808808        pElemInfo->id.numid = id;
    809         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_INFO, (ULONG)pElemInfo);
     809        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_CTL_IOCTL_ELEM_INFO, (ULONG)pElemInfo);
    810810        ret = pHandle->file.f_op->release(&pHandle->inode, &pHandle->file);
    811811        if(pHandle) kfree(pHandle);
     
    865865        pElem->id.numid = id;
    866866        pElem->indirect = 0;
    867         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_READ, (ULONG)pElem);
     867        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_CTL_IOCTL_ELEM_READ, (ULONG)pElem);
    868868        ret = pHandle->file.f_op->release(&pHandle->inode, &pHandle->file);
    869869        if(pHandle) kfree(pHandle);
     
    925925        pElem->indirect = 0;
    926926
    927         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_WRITE, (ULONG)pElem);
     927        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_CTL_IOCTL_ELEM_WRITE, (ULONG)pElem);
    928928        ret = pHandle->file.f_op->release(&pHandle->inode, &pHandle->file);
    929929        if(pHandle) kfree(pHandle);
     
    953953
    954954        pHandle->file.f_flags = O_NONBLOCK;
    955         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)params);
     955        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)params);
    956956        return ret;
    957957}
     
    970970
    971971        pHandle->file.f_flags = O_NONBLOCK;
    972         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_PARAMS, (ULONG)params);
     972        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_HW_PARAMS, (ULONG)params);
    973973        return ret;
    974974}
     
    989989        pHandle->file.f_flags = O_NONBLOCK;
    990990
    991         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_SW_PARAMS, (ULONG)params);
     991        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_SW_PARAMS, (ULONG)params);
    992992        return ret;
    993993}
     
    10061006        pHandle->file.f_flags = O_NONBLOCK;
    10071007
    1008         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)status);
     1008        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)status);
    10091009        return ret;
    10101010}
     
    10551055        pHandle->file.f_flags = O_NONBLOCK;
    10561056
    1057         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0);
     1057        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0);
    10581058        return ret;
    10591059}
     
    10701070        pHandle->file.f_flags = O_NONBLOCK;
    10711071
    1072         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PAUSE, pause);
     1072        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_PAUSE, pause);
    10731073
    10741074        return ret;
     
    10861086        pHandle->file.f_flags = O_NONBLOCK;
    10871087
    1088         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_START, 0);
     1088        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_START, 0);
    10891089
    10901090        return ret;
     
    11021102        pHandle->file.f_flags = O_NONBLOCK;
    11031103
    1104         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_DROP, 0);
     1104        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_DROP, 0);
    11051105
    11061106        return ret;
  • GPL/trunk/lib32/malloc.c

    r587 r679  
    2929
    3030#include <devhelp.h>
    31 #ifdef KEE
    3231#include <kee.h>
    33 #endif
    3432#include "malloc.h"
    3533
  • GPL/trunk/lib32/memory.c

    r587 r679  
    3232#include <stacktoflat.h>
    3333#include <limits.h>
    34 #ifdef KEE
    3534#include <kee.h>
    36 #endif
    3735#include "malloc.h"
     36#define _I386_PAGE_H
     37typedef struct { unsigned long pgprot; } pgprot_t;
     38#define MAP_NR(addr)            (__pa(addr) >> PAGE_SHIFT)
     39#define PAGE_SHIFT      12
     40#define __PAGE_OFFSET           (0xC0000000)
     41
     42#define PAGE_OFFSET             ((unsigned long)__PAGE_OFFSET)
     43#define __pa(x)                 ((unsigned long)(x)-PAGE_OFFSET)
     44
     45#include <linux/mm.h>
     46#include <linux/slab.h>
     47#include <linux/printk.h>
    3848
    3949#pragma off (unreferenced)
    4050
    4151#define PAGE_SIZE 4096
     52#define min(a,b)  (((a) < (b)) ? (a) : (b))
    4253
    4354int free_pages(unsigned long addr, unsigned long order);
     
    6071
    6172typedef struct _BaseAddr {
    62     ULONG                  base;
    63     ULONG                  retaddr;
    64     ULONG                  size;
     73    ULONG                  base;        // VMAlloc addr
     74    ULONG                  retaddr;     // aligned addr returned to caller
     75    ULONG                  size;        // VMAlloc size
    6576    struct _BaseAddr NEAR *next;
    6677} BaseAddr;
     
    93104//******************************************************************************
    94105//******************************************************************************
    95 ULONG GetBaseAddress(ULONG addr, ULONG *pSize)
     106ULONG GetBaseAddressAndFree(ULONG addr, ULONG *pSize)
    96107{
    97108    BaseAddr NEAR *pCur, NEAR *pTemp;
     
    102113    pCur = pBaseAddrHead;
    103114
     115    // If address is in list, remove list item and free entry
     116    // Caller must VMFree returned address or else
    104117    if(pCur->retaddr == addr)
    105118    {
     
    126139}
    127140//******************************************************************************
     141//******************************************************************************
     142ULONG GetBaseAddressNoFree(ULONG addr, ULONG *pSize)
     143{
     144    BaseAddr NEAR *pCur, NEAR *pTemp;
     145
     146    if(pBaseAddrHead == NULL) return addr;
     147
     148    DevCli();
     149    pCur = pBaseAddrHead;
     150
     151    if(pCur->retaddr == addr)
     152    {
     153        addr = pCur->base;
     154        if(pSize) *pSize = pCur->size;
     155        pBaseAddrHead = pCur->next;
     156//        _kfree(pCur);
     157    }
     158    else
     159    while(pCur->next) {
     160        if(pCur->next->retaddr == addr) {
     161            pTemp = pCur->next;
     162            addr = pTemp->base;
     163            if(pSize) *pSize = pTemp->size;
     164            pCur->next = pTemp->next;
     165//            _kfree(pTemp);
     166            break;
     167        }
     168        pCur = pCur->next;
     169    }
     170    DevSti();
     171    return addr;
     172}
     173//******************************************************************************
    128174//NOTE: Assumes memory is continuous!!
    129175//******************************************************************************
    130176unsigned long virt_to_phys(void * address)
    131177{
    132 #ifdef KEE
    133178    KEEVMPageList pagelist;
    134179    ULONG         nrpages;
     
    139184        }
    140185        return pagelist.addr;
    141 #else
    142     LINEAR addr = (LINEAR)address;
    143     PAGELIST pagelist;
    144 
    145         if(DevLinToPageList(addr, PAGE_SIZE, (PAGELIST NEAR *)__Stack32ToFlat((ULONG)&pagelist))) {
    146                 DebugInt3();
    147                 return 0;
    148         }
    149         return pagelist.physaddr;
    150 #endif
    151186}
    152187//******************************************************************************
     
    157192    ULONG addr = 0;
    158193
    159 #ifdef KEE
    160194    SHORT sel;
    161195    rc = KernVMAlloc(PAGE_SIZE, VMDHA_PHYS, (PVOID*)&addr, (PVOID*)&address, &sel);
    162 #else
    163     rc = DevVMAlloc(VMDHA_PHYS, PAGE_SIZE, (LINEAR)&address, __Stack32ToFlat((ULONG)&addr));
    164 #endif
    165196    if (rc != 0) {
    166197        DebugInt3();
     
    184215__again:
    185216
    186 #ifdef KEE
    187 
    188217    rc = KernVMAlloc(size, flags, (PVOID*)&addr, (PVOID*)-1, &sel);
    189 #else
    190     rc = DevVMAlloc(flags, size, (LINEAR)-1, __Stack32ToFlat((ULONG)&addr));
    191 #endif
    192218    if (rc == 0) {
    193219        *pAddr = (LINEAR)addr;
     
    209235{
    210236    APIRET rc;
    211 
    212 #ifdef KEE
    213         rc = KernVMFree((PVOID)addr);
    214 #else
    215         rc = DevVMFree((LINEAR)addr);
    216 #endif
     237    rc = KernVMFree((PVOID)addr);
    217238    if(rc) {
    218239        DebugInt3();
     
    224245ULONG ulget_free_pagesMemUsed = 0;
    225246
    226 #define GFP_DMA         0x80
    227 #define GFP_DMAHIGHMEM  0x100
    228247//******************************************************************************
    229248//******************************************************************************
     
    243262
    244263        if(startpage != endpage) {
    245             //try once more
     264            // not in same 32K page, try once more
    246265            rc = VMAlloc(size, flags, (LINEAR *)&tempaddr);
    247266            VMFree((LINEAR)addr);
     
    333352
    334353            if (startpage != endpage) {
     354                // Not in same 32K page
    335355                physaddr2 = (startpage+1) << 16;
    336356
     
    363383
    364384    //check if it really is the base of the allocation (see above)
    365     addr = GetBaseAddress(addr, (ULONG NEAR *)__Stack32ToFlat(&size));
     385    addr = GetBaseAddressAndFree(addr, (ULONG NEAR *)&size);
    366386
    367387    if(VMFree((LINEAR)addr)) {
     
    402422//******************************************************************************
    403423//******************************************************************************
     424void *__vmalloc(unsigned long size, gfp_t gfp_mask)
     425{
     426        return vmalloc(size);
     427}
     428//******************************************************************************
     429//******************************************************************************
     430/**
     431 * __vmalloc_node - allocate virtually contiguous memory
     432 * @size:           allocation size
     433 * @align:          desired alignment
     434 * @gfp_mask:       flags for the page level allocator
     435 * @node:           node to use for allocation or NUMA_NO_NODE
     436 * @caller:         caller's return address
     437 *
     438 * Allocate enough pages to cover @size from the page level allocator with
     439 * @gfp_mask flags.  Map them into contiguous kernel virtual space.
     440 *
     441 * Reclaim modifiers in @gfp_mask - __GFP_NORETRY, __GFP_RETRY_MAYFAIL
     442 * and __GFP_NOFAIL are not supported
     443 *
     444 * Any use of gfp flags outside of GFP_KERNEL should be consulted
     445 * with mm people.
     446 *
     447 * Return: pointer to the allocated memory or %NULL on error
     448 */
     449void *__vmalloc_node(unsigned long size, unsigned long align,
     450                            gfp_t gfp_mask, int node, const void *caller)
     451{
     452        return vmalloc(size);
     453}
     454//******************************************************************************
     455//******************************************************************************
    404456void vfree(void *ptr)
    405457{
     
    407459    ULONG  size = 0;
    408460
    409     GetBaseAddress((ULONG)ptr, (ULONG NEAR *)__Stack32ToFlat(&size));
     461    GetBaseAddressAndFree((ULONG)ptr, (ULONG NEAR *)&size);
    410462
    411463    if(VMFree((LINEAR)ptr)) {
     
    427479//******************************************************************************
    428480//******************************************************************************
    429 int remap_page_range(unsigned long from, unsigned long to, unsigned long size, unsigned long prot)
     481int remap_page_range(unsigned long from, unsigned long to, unsigned long size, pgprot_t prot)
    430482{
    431483        DebugInt3();
     
    452504        //size &= 0xFFFFF000;
    453505
    454 #ifdef KEE
    455506    SHORT sel;
    456 
    457         //rc = KernVMAlloc(size, VMDHA_PHYS, (PVOID*)&addr, (PVOID*)&physaddr, &sel);
     507    //rc = KernVMAlloc(size, VMDHA_PHYS, (PVOID*)&addr, (PVOID*)&physaddr, &sel);
    458508    rc = KernVMAlloc(Length, VMDHA_PHYS, (PVOID*)&addr, (PVOID*)&PhysicalAddress, &sel);
    459 #else
    460     //rc = DevVMAlloc(VMDHA_PHYS, size, (LINEAR)&physaddr, __Stack32ToFlat((ULONG)&addr));
    461     rc = DevVMAlloc(VMDHA_PHYS, Length, (LINEAR)&PhysicalAddress, __Stack32ToFlat((ULONG)&addr));
    462 #endif
    463509    if (rc != 0) {
    464510        dprintf(("ioremap error: %x", rc));
     
    497543    if(n == 0) return;
    498544
    499         kmemcpy(to, from, n);
     545        memcpy(to, from, n);
    500546}
    501547//******************************************************************************
     
    509555    if(n == 0) return 0;
    510556
    511         kmemcpy(to, from, n);
     557        memcpy(to, from, n);
    512558        return 0;
    513559}
     
    534580    if(n == 0) return 0;
    535581
    536         kmemcpy(to, from, n);
     582        memcpy(to, from, n);
    537583        return 0;
    538584}
     
    547593                return 0;
    548594        }
    549         kmemcpy(dest, src, size);
     595        memcpy(dest, src, size);
    550596        return 0;
    551597}
     
    638684        return kzalloc(n * size, flags);
    639685}
    640 
     686//******************************************************************************
     687//******************************************************************************
     688
     689size_t ksize(const void *block)
     690{
     691        size_t size;
     692
     693        if (!block)
     694            size = 0;                   // Bad coder
     695
     696        else if (block == ZERO_SIZE_PTR)
     697            size = 0;                   // Bad coder
     698
     699        else if(IsHeapAddr((ULONG)block))
     700            size = _msize((void _near *)block);
     701
     702        else if (!GetBaseAddressNoFree((ULONG)block, (ULONG NEAR *)&size))
     703            size = 0;                   // Something wrong
     704
     705        return size;
     706}
     707//******************************************************************************
     708//******************************************************************************
     709static inline void *__do_krealloc(const void *p, size_t new_size,
     710                                           gfp_t flags)
     711{
     712        void *ret;
     713        size_t ks = 0;
     714
     715        if (p)
     716                ks = ksize(p);
     717
     718        if (ks >= new_size)
     719                return (void *)p;
     720
     721        ret = __kmalloc(new_size, flags);
     722        if (ret && p)
     723                memcpy(ret, p, ks);
     724
     725        return ret;
     726}
     727//******************************************************************************
     728//******************************************************************************
     729/**
     730 * krealloc - reallocate memory. The contents will remain unchanged.
     731 * @p: object to reallocate memory for.
     732 * @new_size: how many bytes of memory are required.
     733 * @flags: the type of memory to allocate.
     734 *
     735 * The contents of the object pointed to are preserved up to the
     736 * lesser of the new and old sizes.  If @p is %NULL, krealloc()
     737 * behaves exactly like kmalloc().  If @new_size is 0 and @p is not a
     738 * %NULL pointer, the object pointed to is freed.
     739 */
     740void *krealloc(const void *p, size_t new_size, gfp_t flags)
     741{
     742        void *ret;
     743
     744        if (!new_size) {
     745                kfree(p);
     746                return ZERO_SIZE_PTR;
     747        }
     748
     749        ret = __do_krealloc(p, new_size, flags);
     750        if (ret && p != ret)
     751                kfree(p);
     752
     753        return ret;
     754}
     755//******************************************************************************
     756//******************************************************************************
     757/**
     758 *      vzalloc - allocate virtually contiguous memory with zero fill
     759 *      @size:  allocation size
     760 *      Allocate enough pages to cover @size from the page level
     761 *      allocator and map them into contiguous kernel virtual space.
     762 *      The memory allocated is set to zero.
     763 *
     764 *      For tight control over page level allocator and protection flags
     765 *      use __vmalloc() instead.
     766 */
     767void *vzalloc(unsigned long size)
     768{
     769        void *buf;
     770        buf = vmalloc(size);
     771        if (buf)
     772                memset(buf, 0, size);
     773        return buf;
     774}
     775//******************************************************************************
     776//******************************************************************************
     777/**
     778 * kvmalloc_node - attempt to allocate physically contiguous memory, but upon
     779 * failure, fall back to non-contiguous (vmalloc) allocation.
     780 * @size: size of the request.
     781 * @flags: gfp mask for the allocation - must be compatible (superset) with GFP_KERNEL.
     782 * @node: numa node to allocate from
     783 *
     784 * Uses kmalloc to get the memory but if the allocation fails then falls back
     785 * to the vmalloc allocator. Use kvfree for freeing the memory.
     786 *
     787 * Reclaim modifiers - __GFP_NORETRY and __GFP_NOFAIL are not supported.
     788 * __GFP_RETRY_MAYFAIL is supported, and it should be used only if kmalloc is
     789 * preferable to the vmalloc fallback, due to visible performance drawbacks.
     790 *
     791 * Please note that any use of gfp flags outside of GFP_KERNEL is careful to not
     792 * fall back to vmalloc.
     793 *
     794 * Return: pointer to the allocated memory of %NULL in case of failure
     795 */
     796void *kvmalloc_node(size_t size, gfp_t flags, int node)
     797{
     798        gfp_t kmalloc_flags = flags;
     799        void *ret;
     800
     801        /*
     802         * vmalloc uses GFP_KERNEL for some internal allocations (e.g page tables)
     803         * so the given set of flags has to be compatible.
     804         */
     805        if ((flags & GFP_KERNEL) != GFP_KERNEL)
     806                return kmalloc_node(size, flags, node);
     807
     808        /*
     809         * We want to attempt a large physically contiguous block first because
     810         * it is less likely to fragment multiple larger blocks and therefore
     811         * contribute to a long term fragmentation less than vmalloc fallback.
     812         * However make sure that larger requests are not too disruptive - no
     813         * OOM killer and no allocation failure warnings as we have a fallback.
     814         */
     815        if (size > PAGE_SIZE) {
     816                kmalloc_flags |= __GFP_NOWARN;
     817
     818                if (!(kmalloc_flags & __GFP_RETRY_MAYFAIL))
     819                        kmalloc_flags |= __GFP_NORETRY;
     820        }
     821
     822        ret = kmalloc_node(size, kmalloc_flags, node);
     823
     824        /*
     825         * It doesn't really make sense to fallback to vmalloc for sub page
     826         * requests
     827         */
     828        if (ret || size <= PAGE_SIZE)
     829                return ret;
     830
     831        return __vmalloc_node(size, 1, flags, node,
     832                        __builtin_return_address(0));
     833}
     834//******************************************************************************
     835//******************************************************************************
  • GPL/trunk/lib32/misc.c

    r598 r679  
    2929#include <linux/fs.h>
    3030#include <linux/poll.h>
    31 #define CONFIG_PROC_FS
     31#define CONFIG_PROC_FS 1
    3232#include <linux/proc_fs.h>
    3333#include <asm/uaccess.h>
     
    3838#include <linux/workqueue.h>
    3939#include <linux/firmware.h>
     40#include <linux/ctype.h>
    4041#include <dbgos2.h>
    4142
     
    8485    return 0;
    8586}
     87
     88//******************************************************************************
     89//Save error message in szLastALSAError; if card init failed, then we will
     90//print it in drv32\init.cpp
     91//******************************************************************************
     92int dev_dbg(const struct device *dev, const char * fmt, ...)
     93{
     94    va_list argptr;                /* -> variable argument list */
     95
     96    char *pszLastALSAError;
     97
     98    pszLastALSAError= iLastError ? szLastALSAError2 : szLastALSAError1;
     99
     100    va_start(argptr, fmt);           /* get pointer to argument list */
     101    vsprintf(pszLastALSAError, fmt, argptr);
     102//    strcat(pszLastALSAError, "\r");
     103    va_end(argptr);                /* done with variable arguments */
     104
     105    if(szOverrunTest1 != 0xCC || szOverrunTest2 != 0xCC) {
     106        DebugInt3();
     107    }
     108
     109        StringOut(pszLastALSAError);
     110//    rprintf( (pszLastALSAError) );
     111    if(++iLastError > 1) {
     112        iLastError = 0;
     113    }
     114    return 0;
     115}
     116//******************************************************************************
     117int pcm_dbg(struct snd_pcm *dev, const char * fmt, ...)
     118{
     119    va_list argptr;                /* -> variable argument list */
     120
     121    char *pszLastALSAError;
     122
     123    pszLastALSAError= iLastError ? szLastALSAError2 : szLastALSAError1;
     124
     125    va_start(argptr, fmt);           /* get pointer to argument list */
     126    vsprintf(pszLastALSAError, fmt, argptr);
     127//    strcat(pszLastALSAError, "\r");
     128    va_end(argptr);                /* done with variable arguments */
     129
     130    if(szOverrunTest1 != 0xCC || szOverrunTest2 != 0xCC) {
     131        DebugInt3();
     132    }
     133
     134        StringOut(pszLastALSAError);
     135//    rprintf( (pszLastALSAError) );
     136    if(++iLastError > 1) {
     137        iLastError = 0;
     138    }
     139    return 0;
     140}
     141//******************************************************************************
     142int codec_dbg(struct hda_codec *dev, const char * fmt, ...)
     143{
     144    va_list argptr;                /* -> variable argument list */
     145
     146    char *pszLastALSAError;
     147
     148    pszLastALSAError= iLastError ? szLastALSAError2 : szLastALSAError1;
     149
     150    va_start(argptr, fmt);           /* get pointer to argument list */
     151    vsprintf(pszLastALSAError, fmt, argptr);
     152//    strcat(pszLastALSAError, "\r");
     153    va_end(argptr);                /* done with variable arguments */
     154
     155    if(szOverrunTest1 != 0xCC || szOverrunTest2 != 0xCC) {
     156        DebugInt3();
     157    }
     158
     159        StringOut(pszLastALSAError);
     160//    rprintf( (pszLastALSAError) );
     161    if(++iLastError > 1) {
     162        iLastError = 0;
     163    }
     164    return 0;
     165}
    86166//******************************************************************************
    87167//******************************************************************************
     
    169249//******************************************************************************
    170250//******************************************************************************
     251struct proc_dir_entry *proc_mkdir_mode(const char *name, umode_t mode,
     252        struct proc_dir_entry *parent){
     253    struct proc_dir_entry *proc;
     254    proc = (struct proc_dir_entry *)kmalloc(sizeof(struct proc_dir_entry), 0);
     255    memset(proc, 0, sizeof(struct proc_dir_entry));
     256
     257    proc->name   = name;
     258    proc->parent = parent;
     259
     260    return proc;
     261}
     262//******************************************************************************
     263//******************************************************************************
     264struct proc_dir_entry *proc_mkdir(const char *name, struct proc_dir_entry *parent)
     265{
     266    return proc_mkdir_mode(name, S_IRUGO | S_IXUGO, parent);
     267}
     268//******************************************************************************
     269//******************************************************************************
     270struct proc_dir_entry *proc_symlink(const char *name, struct proc_dir_entry *parent, const char *dest)
     271{
     272    struct proc_dir_entry *proc;
     273    proc = (struct proc_dir_entry *)kmalloc(sizeof(struct proc_dir_entry), 0);
     274    memset(proc, 0, sizeof(struct proc_dir_entry));
     275
     276    proc->name   = name;
     277    proc->parent = parent;
     278    proc->data = (void*)dest;
     279
     280    return proc;
     281}
     282//******************************************************************************
     283//******************************************************************************
    171284int fasync_helper(int a, struct file *b, int c, struct fasync_struct **d)
    172285{
     
    175288//******************************************************************************
    176289//******************************************************************************
    177 void kill_fasync(struct fasync_struct *a, int b, int c)
     290void kill_fasync(struct fasync_struct **a, int b, int c)
    178291{
    179292}
     
    273386                run_workqueue(wq);
    274387        } else {
    275                 wait_queue_t wait;
     388                struct wait_queue_entry wait;
    276389
    277390                init_waitqueue_entry(&wait, current);
     
    399512//******************************************************************************
    400513//******************************************************************************
    401 void *memdup_user(void __user *src, size_t len)
     514void *memdup_user(const void __user *src, size_t len)
    402515{
    403516        void *p = kmalloc(len, GFP_KERNEL);
     
    425538//******************************************************************************
    426539//******************************************************************************
    427 int schedule_work(struct work_struct *works)
    428 {
    429 #ifndef TARGET_OS2
    430         return kernel_thread(work_caller, works, 0) >= 0;
    431 #else
    432         return 1;
     540struct workqueue_struct *system_wq;
     541
     542int schedule_work(struct work_struct *work)
     543{
     544#ifndef TARGET_OS2 // crashes
     545        return queue_work(system_wq, work);
    433546#endif
    434 }
     547        return 0;
     548}
     549
    435550//******************************************************************************
    436551//******************************************************************************
     
    517632        return -EINVAL;
    518633}
     634//******************************************************************************
     635//******************************************************************************
     636
     637static void u32_swap(void *a, void *b, int size)
     638{
     639        u32 t = *(u32 *)a;
     640        *(u32 *)a = *(u32 *)b;
     641        *(u32 *)b = t;
     642}
     643
     644static void generic_swap(void *a, void *b, int size)
     645{
     646        char t;
     647
     648        do {
     649                t = *(char *)a;
     650                *(char *)a++ = *(char *)b;
     651                *(char *)b++ = t;
     652        } while (--size > 0);
     653}
     654
     655/**
     656 * sort - sort an array of elements
     657 * @base: pointer to data to sort
     658 * @num: number of elements
     659 * @size: size of each element
     660 * @cmp_func: pointer to comparison function
     661 * @swap_func: pointer to swap function or NULL
     662 *
     663 * This function does a heapsort on the given array. You may provide a
     664 * swap_func function optimized to your element type.
     665 *
     666 * Sorting time is O(n log n) both on average and worst-case. While
     667 * qsort is about 20% faster on average, it suffers from exploitable
     668 * O(n*n) worst-case behavior and extra memory requirements that make
     669 * it less suitable for kernel use.
     670 */
     671
     672void sort(void *base, size_t num, size_t size,
     673          int (*cmp_func)(const void *, const void *),
     674          void (*swap_func)(void *, void *, int size))
     675{
     676        /* pre-scale counters for performance */
     677        int i = (num/2 - 1) * size, n = num * size, c, r;
     678
     679        if (!swap_func)
     680                swap_func = (size == 4 ? u32_swap : generic_swap);
     681
     682        /* heapify */
     683        for ( ; i >= 0; i -= size) {
     684                for (r = i; r * 2 + size < n; r  = c) {
     685                        c = r * 2 + size;
     686                        if (c < n - size &&
     687                                        cmp_func(base + c, base + c + size) < 0)
     688                                c += size;
     689                        if (cmp_func(base + r, base + c) >= 0)
     690                                break;
     691                        swap_func(base + r, base + c, size);
     692                }
     693        }
     694
     695        /* sort */
     696        for (i = n - size; i > 0; i -= size) {
     697                swap_func(base, base + i, size);
     698                for (r = 0; r * 2 + size < i; r = c) {
     699                        c = r * 2 + size;
     700                        if (c < i - size &&
     701                                        cmp_func(base + c, base + c + size) < 0)
     702                                c += size;
     703                        if (cmp_func(base + r, base + c) >= 0)
     704                                break;
     705                        swap_func(base + r, base + c, size);
     706                }
     707        }
     708}
     709//******************************************************************************
     710//******************************************************************************
     711
     712/**
     713 * hex_to_bin - convert a hex digit to its real value
     714 * @ch: ascii character represents hex digit
     715 *
     716 * hex_to_bin() converts one hex digit to its actual value or -1 in case of bad
     717 * input.
     718 */
     719int hex_to_bin(char ch)
     720{
     721        if ((ch >= '0') && (ch <= '9'))
     722                return ch - '0';
     723        ch = tolower(ch);
     724        if ((ch >= 'a') && (ch <= 'f'))
     725                return ch - 'a' + 10;
     726        return -1;
     727}
     728//******************************************************************************
     729
     730
     731/*
     732 * stream_open is used by subsystems that want stream-like file descriptors.
     733 * Such file descriptors are not seekable and don't have notion of position
     734 * (file.f_pos is always 0). Contrary to file descriptors of other regular
     735 * files, .read() and .write() can run simultaneously.
     736 *
     737 * stream_open never fails and is marked to return int so that it could be
     738 * directly used as file_operations.open .
     739 */
     740int stream_open(struct inode *inode, struct file *filp)
     741{
     742        filp->f_mode &= ~(FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE | FMODE_ATOMIC_POS);
     743        //DAZ f_mode is 16 bit so FMODE_STREAM doesn't fit, but we don't use this on OS/2.
     744        //filp->f_mode |= FMODE_STREAM;
     745        return 0;
     746}
     747
     748/**
     749 * alloc_pages_exact - allocate pages with the given size
     750 * @size: the size to allocate in bytes
     751 * @gfp_flags: the allocation conditions, GFP_XXX
     752 *
     753 * Allocates the physically contiguous pages with the given size.
     754 *
     755 * Return: The pointer of the buffer, or %NULL if no enough memory.
     756 */
     757void *alloc_pages_exact(size_t size, gfp_t gfp_flags)
     758{
     759        int pg;
     760
     761        if (WARN_ON(!size))
     762                return NULL;
     763        if (WARN_ON(!gfp_flags))
     764                return NULL;
     765        gfp_flags |= __GFP_COMP;        /* compound page lets parts be mapped */
     766        pg = get_order(size);
     767        return (void *) __get_free_pages(gfp_flags, pg);
     768}
     769
     770/**
     771 * free_pages_exact - release the pages
     772 * @ptr: the buffer pointer to release
     773 * @size: the allocated buffer size
     774 *
     775 * Releases the buffer allocated via snd_malloc_pages().
     776 */
     777void free_pages_exact(void *ptr, size_t size)
     778{
     779        int pg;
     780
     781        if (ptr == NULL)
     782                return;
     783        pg = get_order(size);
     784        free_pages((unsigned long) ptr, pg);
     785}
  • GPL/trunk/lib32/ossidc.c

    r607 r679  
    3232#include <unicard.h>
    3333#include <version.h>
    34 #ifdef KEE
    35 #include <kee.h>
    36 #endif
    3734#include "initcall.h"
     35#include <u32ioctl.h>
    3836
    3937extern DWORD TimerHandler16;    //drv32\strategy.asm
     
    6664
    6765cardcalls_t cardcalls[CARDS_NUM] = {
    68         { CARD_ICH,              &name_module_init(alsa_card_intel8x0_init),    &name_module_exit(alsa_card_intel8x0_exit)        },
    69         { CARD_VIA82XX,  &name_module_init(alsa_card_via82xx_init),             &name_module_exit(alsa_card_via82xx_exit)         },
    70         { CARD_SBLIVE,   &name_module_init(alsa_card_emu10k1_init),             &name_module_exit(alsa_card_emu10k1_exit)         },
    71         { CARD_CMEDIA,   &name_module_init(alsa_card_cmipci_init),              &name_module_exit(alsa_card_cmipci_exit)          },
    72         { CARD_ALS4000,  &name_module_init(alsa_card_als4000_init),             &name_module_exit(alsa_card_als4000_exit)         },
    73         { CARD_CS4281,   &name_module_init(alsa_card_cs4281_init),              &name_module_exit(alsa_card_cs4281_exit)          },
    74         { CARD_CS46XX,   &name_module_init(alsa_card_cs46xx_init),              &name_module_exit(alsa_card_cs46xx_exit)          },
    75         { CARD_CS5535,   &name_module_init(alsa_card_cs5535audio_init), &name_module_exit(alsa_card_cs5535audio_exit) },
    76         { CARD_ESS1938,  &name_module_init(alsa_card_es1938_init),              &name_module_exit(alsa_card_es1938_exit)          },
    77         { CARD_ENSONIQ0, &name_module_init(alsa_card_ens1370_init),             &name_module_exit(alsa_card_ens1370_exit)         },
    78         { CARD_ENSONIQ1, &name_module_init(alsa_card_ens1371_init),             &name_module_exit(alsa_card_ens1371_exit)         },
    79         { CARD_YAMAHA,   &name_module_init(alsa_card_ymfpci_init),              &name_module_exit(alsa_card_ymfpci_exit)          },
    80         { CARD_MAESTRO,  &name_module_init(alsa_card_es1968_init),              &name_module_exit(alsa_card_es1968_exit)          },
    81         { CARD_MAESTRO3, &name_module_init(alsa_card_m3_init),                  &name_module_exit(alsa_card_m3_exit)              },
    82         { CARD_ALI5451,  &name_module_init(alsa_card_ali_init),                 &name_module_exit(alsa_card_ali_exit)             },
    83         { CARD_TRIDENT,  &name_module_init(alsa_card_trident_init),             &name_module_exit(alsa_card_trident_exit)         },
     66        { CARD_ICH,      &name_module_init(intel8x0_driver_init),       &name_module_exit(intel8x0_driver_exit)   },
     67        { CARD_VIA82XX,  &name_module_init(via82xx_driver_init),        &name_module_exit(via82xx_driver_exit)    },
     68        { CARD_SBLIVE,   &name_module_init(emu10k1_driver_init),        &name_module_exit(emu10k1_driver_exit)    },
     69        { CARD_CMEDIA,   &name_module_init(cmipci_driver_init),         &name_module_exit(cmipci_driver_exit)     },
     70        { CARD_ALS4000,  &name_module_init(als4000_driver_init),        &name_module_exit(als4000_driver_exit)    },
     71        { CARD_CS4281,   &name_module_init(cs4281_driver_init),         &name_module_exit(cs4281_driver_exit)     },
     72        { CARD_CS46XX,   &name_module_init(cs46xx_driver_init),         &name_module_exit(cs46xx_driver_exit)     },
     73        { CARD_CS5535,   &name_module_init(cs5535audio_driver_init),    &name_module_exit(cs5535audio_driver_exit) },
     74        { CARD_ESS1938,  &name_module_init(es1938_driver_init),         &name_module_exit(es1938_driver_exit)     },
     75        { CARD_ENSONIQ0, &name_module_init(ens137x_driver_init),        &name_module_exit(ens137x_driver_exit)    },
     76        { CARD_ENSONIQ1, NULL,                                          NULL                                      },
     77        { CARD_YAMAHA,   &name_module_init(ymfpci_driver_init),         &name_module_exit(ymfpci_driver_exit)     },
     78        { CARD_MAESTRO,  &name_module_init(es1968_driver_init),         &name_module_exit(es1968_driver_exit)     },
     79        { CARD_MAESTRO3, &name_module_init(m3_driver_init),             &name_module_exit(m3_driver_exit)         },
     80        { CARD_ALI5451,  &name_module_init(ali5451_driver_init),        &name_module_exit(ali5451_driver_exit)    },
     81        { CARD_TRIDENT,  &name_module_init(trident_driver_init),        &name_module_exit(trident_driver_exit)    },
    8482#ifdef VORTEX
    85         { CARD_VORTEX,   &name_module_init(alsa_card_vortex_init),              &name_module_exit(alsa_card_vortex_exit)          },
     83        { CARD_VORTEX,   &name_module_init(vortex_driver_init),         &name_module_exit(vortex_driver_exit)     },
    8684#else
    87         { CARD_VORTEX,   NULL,          NULL },
     85        { CARD_VORTEX,   NULL,                                          NULL                                      },
    8886#endif
    89         { CARD_NEOMAGIC, &name_module_init(alsa_card_nm256_init),               &name_module_exit(alsa_card_nm256_exit)           },
    90         { CARD_FM801,    &name_module_init(alsa_card_fm801_init),               &name_module_exit(alsa_card_fm801_exit)           },
    91         { CARD_ATIIXP,   &name_module_init(alsa_card_atiixp_init),              &name_module_exit(alsa_card_atiixp_exit)          },
    92         { CARD_AUDIGYLS, &name_module_init(alsa_card_ca0106_init),              &name_module_exit(alsa_card_ca0106_exit)          },
    93         { CARD_AZX,              &name_module_init(alsa_card_azx_init),                 &name_module_exit(alsa_card_azx_exit)             },
    94         { CARD_BT87X,    &name_module_init(alsa_card_bt87x_init),               &name_module_exit(alsa_card_bt87x_exit)           },
     87        { CARD_NEOMAGIC, &name_module_init(nm256_driver_init),          &name_module_exit(nm256_driver_exit)      },
     88        { CARD_FM801,    &name_module_init(fm801_driver_init),          &name_module_exit(fm801_driver_exit)      },
     89        { CARD_ATIIXP,   &name_module_init(atiixp_driver_init),         &name_module_exit(atiixp_driver_exit)     },
     90        { CARD_AUDIGYLS, &name_module_init(ca0106_driver_init),         &name_module_exit(ca0106_driver_exit)     },
     91        { CARD_AZX,      &name_module_init(azx_driver_init),            &name_module_exit(azx_driver_exit)        },
     92        { CARD_BT87X,    &name_module_init(alsa_card_bt87x_init),       &name_module_exit(alsa_card_bt87x_exit)   },
    9593};
    9694
     
    9896int        fStrategyInit = FALSE;
    9997void pcm_info(void);
    100 void FillCaps(ULONG deviceid);
    10198
    10299//******************************************************************************
     
    115112        dprintf(("OSS32_Initialize: Start address: %X", OffsetBeginCS32));
    116113
    117         if(call_module_init(alsa_sound_init) != 0)               return OSSERR_INIT_FAILED;
     114        if(call_module_init(alsa_sound_init) != 0)              return OSSERR_INIT_FAILED;
     115        if(call_module_init(alsa_seq_device_init) != 0)         return OSSERR_INIT_FAILED;
    118116        dprintf(("OSS32_Initialize1: Start address: %X", OffsetBeginCS32));
    119         if(call_module_init(alsa_pcm_init) != 0)                 return OSSERR_INIT_FAILED;
    120         if(call_module_init(alsa_hwdep_init) != 0)               return OSSERR_INIT_FAILED;
    121         if(call_module_init(alsa_timer_init) != 0)               return OSSERR_INIT_FAILED;
    122 
    123         if(call_module_init(alsa_rawmidi_init) != 0)     return OSSERR_INIT_FAILED;
    124         if(call_module_init(alsa_seq_init) != 0)                 return OSSERR_INIT_FAILED;
    125         if(call_module_init(alsa_opl3_init) != 0)                return OSSERR_INIT_FAILED;
    126         if(call_module_init(alsa_opl3_seq_init) != 0)    return OSSERR_INIT_FAILED;
    127 
    128         if(call_module_init(alsa_mpu401_uart_init) != 0) return OSSERR_INIT_FAILED;
     117        if(call_module_init(alsa_pcm_init) != 0)                return OSSERR_INIT_FAILED;
     118        if(call_module_init(alsa_hwdep_init) != 0)              return OSSERR_INIT_FAILED;
     119        if(call_module_init(alsa_timer_init) != 0)              return OSSERR_INIT_FAILED;
     120
     121        if(call_module_init(alsa_rawmidi_init) != 0)            return OSSERR_INIT_FAILED;
     122        if(call_module_init(alsa_seq_init) != 0)                return OSSERR_INIT_FAILED;
     123        call_module_init(opl3_seq_driver_init); 
     124        call_module_init(regmap_initcall);
    129125
    130126        /* Init functions for HDA audio */
    131         call_module_init(patch_analog_init);
    132         //call_module_init(patch_atihdmi_init);
    133         call_module_init(patch_cmedia_init);
    134         call_module_init(patch_conexant_init);
    135         call_module_init(patch_realtek_init);
    136         call_module_init(patch_sigmatel_init);
    137         call_module_init(patch_via_init);
     127        call_module_init(hda_bus_init);
     128        call_module_init(generic_driver_init);
     129        call_module_init(analog_driver_init);
     130        call_module_init(ca0110_driver_init);
     131        call_module_init(cirrus_driver_init);
     132        call_module_init(cmedia_driver_init);
     133        call_module_init(conexant_driver_init);
     134//      call_module_init(hdmi_driver_init);
     135        call_module_init(realtek_driver_init);
     136        call_module_init(sigmatel_driver_init);
     137        call_module_init(via_driver_init);
    138138
    139139        //dprintf(("OSS32_Initialize: ForceCard=%d", ForceCard));
     
    178178        }
    179179
    180         call_module_exit(alsa_mpu401_uart_exit);
    181         call_module_exit(alsa_opl3_seq_exit);
    182         call_module_exit(alsa_opl3_exit);
     180        call_module_exit(opl3_seq_driver_exit);
    183181        call_module_exit(alsa_seq_exit);
    184182        call_module_exit(alsa_rawmidi_exit);
     
    186184        call_module_exit(alsa_hwdep_exit);
    187185        call_module_exit(alsa_pcm_exit);
     186        call_module_exit(alsa_seq_device_exit);
    188187        call_module_exit(alsa_sound_exit);
    189188
     
    208207
    209208//******************************************************************************
    210 int MyDevBlock(ULONG id, ULONG tout, char flag)
    211 {
    212         return DevBlock(id,tout, flag);
    213 }
    214209
    215210int OSS32_DebugString(char *buffer, ULONG size)
  • GPL/trunk/lib32/pci.c

    r604 r679  
    2525 *
    2626 */
    27 
     27#define CONFIG_PM
    2828#include "linux.h"
    2929#include <linux/init.h>
    3030#include <linux/poll.h>
     31#include <linux/dma-mapping.h>
    3132#include <asm/uaccess.h>
    3233#include <asm/hardirq.h>
     
    183184        memset((void near *)pcidev, 0, sizeof(struct pci_dev));
    184185
    185         pcidev->_class = ulTmp2;
     186        pcidev->class = ulTmp2;
    186187        pcidev->vendor = detectedId & 0xffff;
    187188        pcidev->device = detectedId >> 16;
     
    201202        pcidev->sibling = NULL;
    202203        pcidev->next = NULL;
    203         pcidev->dma_mask = 0xFFFFFFFF;
     204        pcidev->dma_mask = 0xffffffff;
     205        pcidev->dev.dma_mask = &pcidev->dma_mask;
     206        pcidev->dev.coherent_dma_mask = 0xffffffffull;
    204207
    205208        // Subsystem ID
    206209        pci_read_config_word(pcidev, PCI_SUBSYSTEM_VENDOR_ID, &pcidev->subsystem_vendor);
    207210        pci_read_config_word(pcidev, PCI_SUBSYSTEM_ID, &pcidev->subsystem_device);
     211
     212        // revision
     213        pci_read_config_byte(pcidev, PCI_REVISION_ID, &pcidev->revision);
    208214
    209215        // I/O  and MEM
     
    296302  if(a->flags & IORESOURCE_MEM) {
    297303    if(RMRequestMem(/*hResMgr,*/ start, n) == FALSE) {
    298       printk("RMRequestIO failed for io %x, length %x\n", start, n);
     304      printk("RMRequestIO failed for mem %x length %x\n", start, n);
    299305      return NULL;
    300306    }
     
    302308  else if(a->flags & IORESOURCE_IO) {
    303309    if(RMRequestIO(/*hResMgr,*/ start, n) == FALSE) {
    304       printk("RMRequestIO failed for io %x, length %x\n", start, n);
     310      printk("RMRequestIO failed for io %x length %x\n", start, n);
    305311      return NULL;
    306312    }
     
    477483  struct pci_dev *pcidev;
    478484  struct pci_device_id IdTable;
     485  USHORT usVendor, usDevice;
    479486  int iAdapter = 0;
    480487
     
    499506    int iTableIx;
    500507
    501     rprintf(("pci_register_driver: query_device found %x %x:%x class=%x checking %s",
    502       ulLast, pcidev->vendor, pcidev->device, pcidev->_class, driver->name));
     508    rprintf((__func__": query_device found %x %04x:%04x class=%x checking %s",
     509      ulLast, pcidev->vendor, pcidev->device, pcidev->class, driver->name));
     510
     511    usVendor = 0;
     512    usDevice = 0;
    503513
    504514    for( iTableIx = 0; driver->id_table[iTableIx].vendor; iTableIx++)
     
    506516      struct pci_device_id const *pDriverId = &driver->id_table[iTableIx];
    507517
    508       if ( (pDriverId->class) && ((pcidev->_class & pDriverId->class_mask) != pDriverId->class) ) continue;
     518      if ( (pDriverId->class) && ((pcidev->class & pDriverId->class_mask) != pDriverId->class) ) continue;
    509519      if (pDriverId->vendor != pcidev->vendor) continue;
    510520      if ( (pDriverId->device != PCI_ANY_ID) && (pDriverId->device != pcidev->device) ) continue;
    511521
    512       rprintf(("pci_register_driver: matched %d %x:%x/%x with %x:%x/%x %x (%s)", iTableIx,
    513         pcidev->vendor, pcidev->device, pcidev->_class,
     522      /* skip a duplicate device that could be matched by both and exact match and a class match */
     523      if (usVendor == pcidev->vendor && usDevice == pcidev->device) continue;
     524      usVendor = pcidev->vendor;
     525      usDevice = pcidev->device;
     526
     527      rprintf((__func__": matched %d %x:%x/%x with %x:%x/%x %x (%s)", iTableIx,
     528        pcidev->vendor, pcidev->device, pcidev->class,
    514529        pDriverId->vendor, pDriverId->device, pDriverId->class, pDriverId->class_mask, driver->name));
    515530
    516531      if ((iAdapterNumber >= 0) && (iAdapter < iAdapterNumber))
    517532      {
     533        rprintf((__func__": AdapterNumber=%x skipping Adapter=%x", iAdapterNumber, iAdapter));
    518534        iAdapter++;
    519535        continue;
    520536      }
    521537
    522       RMInit();
    523538      if (driver->probe(pcidev, pDriverId) == 0)
    524539      {
     
    527542
    528543        // create adapter
    529         RMDone((pcidev->device << 16) | pcidev->vendor, &pcidev->hAdapter, &pcidev->hDevice);
     544        RMCreateAdapterU32((pcidev->device << 16) | pcidev->vendor, &pcidev->hAdapter, ulLast, iNumCards);
     545
    530546        iNumCards++;
    531547        pcidev = NULL; /* we need a new slot */
    532548        break;
    533549      }
    534       RMDone(0, 0, 0);
     550      // release resources which were possibly allocated during probe()
     551      RMDeallocRes();
    535552    } /* for id_table loop */
    536553
     
    647664    //try not to exhaust low memory (< 16mb) so allocate from the high region first
    648665    //if that doesn't satisfy the dma mask requirement, then get it from the low
    649     //regino anyway
     666    //region anyway
    650667    if(hwdev->dma_mask > 0x00ffffff) {
    651668      order = __compat_get_order(size);
     
    666683    ret = (void *)__get_free_pages(gfp, __compat_get_order(size));
    667684  }
    668 
    669685  if (ret != NULL) {
    670686    memset(ret, 0, size);
     
    672688  }
    673689  return ret;
     690}
     691
     692#if 0
     693void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
     694                      dma_addr_t *dma_handle)
     695 {
     696         return dma_alloc_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, dma_handle, GFP_ATOMIC);
     697 }
     698#endif
     699#if 0
     700void *dma_alloc_coherent(struct device *dev, size_t size,
     701                                dma_addr_t *dma_handle, gfp_t gfp)
     702{
     703  void *ret = NULL;
     704  int order;
     705
     706  dprintf(("dma_alloc_coherent %d mask %x", size, (dev) ? dev->dma_mask : 0));
     707  if (dev == NULL || *dev->dma_mask != 0xffffffff) {
     708  dprintf(("dma_alloc_coherent"));
     709    //try not to exhaust low memory (< 16mb) so allocate from the high region first
     710    //if that doesn't satisfy the dma mask requirement, then get it from the low
     711    //region anyway
     712    if(*dev->dma_mask > 0x00ffffff) {
     713  dprintf(("dma_alloc_coherent2"));
     714      order = __compat_get_order(size);
     715      ret = (void *)__get_free_pages(gfp|GFP_DMAHIGHMEM, order);
     716      *dma_handle = virt_to_bus(ret);
     717      if(*dma_handle > *dev->dma_mask) {
     718  dprintf(("dma_alloc_coherent3"));
     719        free_pages((unsigned long)ret, __compat_get_order(size));
     720        //be sure and allocate below 16 mb
     721        gfp |= GFP_DMA;
     722        ret = NULL;
     723      }
     724  dprintf(("dma_alloc_coherent3a"));
     725    }
     726    else { //must always allocate below 16 mb
     727  dprintf(("dma_alloc_coherent4"));
     728      gfp |= GFP_DMA;
     729    }
     730  }
     731  if(ret == NULL) {
     732  dprintf(("dma_alloc_coherent5"));
     733    ret = (void *)__get_free_pages(gfp, __compat_get_order(size));
     734  }
     735
     736  if (ret != NULL) {
     737    memset(ret, 0, size);
     738    *dma_handle = virt_to_bus(ret);
     739  }
     740  return ret;
     741
     742}
     743#endif
     744
     745int dma_supported(struct device *dev, u64 mask)
     746{
     747  return 1;
     748}
     749
     750int dma_set_coherent_mask(struct device *dev, u64 mask)
     751{
     752        /*
     753         * Truncate the mask to the actually supported dma_addr_t width to
     754         * avoid generating unsupportable addresses.
     755         */
     756        mask = (dma_addr_t)mask;
     757
     758        if (!dma_supported(dev, mask))
     759                return -EIO;
     760
     761        dev->coherent_dma_mask = mask;
     762        return 0;
     763}
     764
     765int dma_set_mask(struct device *dev, u64 mask)
     766{
     767        /*
     768         * Truncate the mask to the actually supported dma_addr_t width to
     769         * avoid generating unsupportable addresses.
     770         */
     771        mask = (dma_addr_t)mask;
     772
     773        if (!dev->dma_mask || !dma_supported(dev, mask))
     774                return -EIO;
     775
     776        *dev->dma_mask = mask;
     777        return 0;
    674778}
    675779
     
    888992}
    889993
    890 const struct pci_device_id * pci_match_device(const struct pci_device_id *ids, struct pci_dev *dev)
     994const struct pci_device_id * pci_match_id(const struct pci_device_id *ids, struct pci_dev *dev)
    891995{
    892996  u16 subsystem_vendor, subsystem_device;
     
    9001004      (ids->subvendor == PCI_ANY_ID || ids->subvendor == subsystem_vendor) &&
    9011005      (ids->subdevice == PCI_ANY_ID || ids->subdevice == subsystem_device) &&
    902       !((ids->class ^ dev->_class) & ids->class_mask))
     1006      !((ids->class ^ dev->class) & ids->class_mask))
    9031007      return ids;
    9041008    ids++;
     
    9811085    if(pci_devices[i].devfn)
    9821086    {
    983       RMSetHandles(pci_devices[i].hAdapter, pci_devices[i].hDevice); /* DAZ - dirty hack */
     1087      RMSetHandles(pci_devices[i].hAdapter); /* DAZ - dirty hack */
    9841088      driver = pci_devices[i].pcidriver;
    9851089      if(driver && driver->resume) {
     
    10041108    if(pci_devices[i].devfn)
    10051109    {
    1006       RMSetHandles(pci_devices[i].hAdapter, pci_devices[i].hDevice); /* DAZ - dirty hack */
     1110      RMSetHandles(pci_devices[i].hAdapter); /* DAZ - dirty hack */
    10071111      driver = pci_devices[i].pcidriver;
    10081112      if(driver && driver->suspend) {
     
    10401144#endif
    10411145
     1146/**
     1147 * pci_status_get_and_clear_errors - return and clear error bits in PCI_STATUS
     1148 * @pdev: the PCI device
     1149 *
     1150 * Returns error bits set in PCI_STATUS and clears them.
     1151 */
     1152int pci_status_get_and_clear_errors(struct pci_dev *pdev)
     1153{
     1154        u16 status;
     1155        int ret;
     1156
     1157        ret = pci_read_config_word(pdev, PCI_STATUS, &status);
     1158        if (ret != PCIBIOS_SUCCESSFUL)
     1159                return -EIO;
     1160
     1161        status &= PCI_STATUS_ERROR_BITS;
     1162        if (status)
     1163                pci_write_config_word(pdev, PCI_STATUS, status);
     1164
     1165        return status;
     1166}
     1167
  • GPL/trunk/lib32/sound.c

    r605 r679  
    3737#include <stdlib.h>
    3838#include <proto.h>
    39 //#include <dbgos2.h>
     39#include <u32ioctl.h>
    4040#include "soundoss.h"
    4141
     
    4444#define samples_to_bytes(a)     ((a*pHandle->doublesamplesize)/2)
    4545#define bytes_to_samples(a)    (pHandle->doublesamplesize ? ((a*2)/pHandle->doublesamplesize) : a)
    46 int GetMaxChannels(ULONG deviceid, int type);
    4746
    4847struct file_operations oss_devices[OSS32_MAX_DEVICES] = {0};
    49 struct file_operations *alsa_fops = NULL;
     48const struct file_operations *alsa_fops = NULL;
    5049int per_bytes = 0;
    5150int prev_size = 0;
     
    8079//******************************************************************************
    8180//******************************************************************************
    82 int register_chrdev(unsigned int version, const char *name, struct file_operations *fsop)
     81int register_chrdev(unsigned int version, const char *name, const struct file_operations *fsop)
    8382{
    8483   if(!strcmp(name, "alsa")) {
     
    369368                pHandle->file.f_flags = O_NONBLOCK;
    370369
    371                 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_INFO, (ULONG)pcminfo);
     370                ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_INFO, (ULONG)pcminfo);
    372371                if(ret != 0) {
    373372                        rprintf(("OSS32_QueryDevCaps: SNDRV_PCM_IOCTL_INFO error %i\n", ret));
     
    386385                //get all hardware parameters
    387386                _snd_pcm_hw_params_any(params);
    388                 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)params);
     387                ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)params);
    389388                if(ret != 0) {
    390389                        rprintf(("OSS32_QueryDevCaps: SNDRV_PCM_IOCTL_HW_REFINE error %i\n", ret));
     
    539538
    540539        ret = alsa_fops->open(&pHandle->inode, &pHandle->file);
     540
    541541        //dprintf(("OSS32_WaveOpen. ret: %i\n", ret));
    542542        /* check if PCM already opened (stupid uniaud16.sys doesnt closes it) */
     
    627627                        {
    628628                                /* prepare for reuse */
    629                                 pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_RESET, 0);
    630                                 pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0);
     629                                pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_RESET, 0);
     630                                pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0);
    631631                        }
    632632                        break;
     
    668668        pHandle->file.f_flags = O_NONBLOCK;
    669669
    670         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0);
     670        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0);
    671671        if (ret)
    672672                rprintf(("Wave prepare ret = %i, streamid %X\n",ret,(ULONG)pHandle));
     
    687687        //set operation to non-blocking
    688688        pHandle->file.f_flags = O_NONBLOCK;
    689         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_START, 0);
     689        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_START, 0);
    690690        if (ret)
    691691                rprintf(("Wave start ret = %i, streamid %X\n",ret,(ULONG)pHandle));
     
    707707        pHandle->file.f_flags = O_NONBLOCK;
    708708
    709         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_DROP, 0);
     709        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_DROP, 0);
    710710        if (ret)
    711711                rprintf(("Wave stop ret = %i. streamid %X\n",ret,(ULONG)pHandle));
     
    727727        pHandle->file.f_flags = O_NONBLOCK;
    728728
    729         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PAUSE, 0);
     729        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_PAUSE, 0);
    730730        if (ret)
    731731                rprintf(("Wave pause ret = %i, streamid %X\n",ret,(ULONG)pHandle));
     
    747747        pHandle->file.f_flags = O_NONBLOCK;
    748748
    749         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PAUSE, 1);
     749        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_PAUSE, 1);
    750750        if (ret)
    751751                rprintf(("Wave resume ret = %i, streamid %X\n",ret,(ULONG)pHandle));
     
    815815                _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_CHANNELS,
    816816                                                          pHwParams->ulNumChannels, 0);
    817                 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)__Stack32ToFlat(&params));
     817                ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)&params);
    818818                if (ret == 0) break;
    819819                pHwParams->ulNumChannels--;
     
    828828        _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_FORMAT,
    829829                                                   OSSToALSADataType[pHwParams->ulDataType], 0);
    830         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)__Stack32ToFlat(&params));
     830        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)&params);
    831831        if(ret != 0) {
    832832                rprintf(("invalid format %lx\n", OSSToALSADataType[pHwParams->ulDataType]));
     
    835835        _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
    836836                                                  pHwParams->ulBitsPerSample, 0);
    837         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)__Stack32ToFlat(&params));
     837        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)&params);
    838838        if(ret != 0) {
    839839                rprintf(("invalid number of sample bits %d\n", pHwParams->ulBitsPerSample));
     
    842842        _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_FRAME_BITS,
    843843                                                  pHwParams->ulBitsPerSample*pHwParams->ulNumChannels, 0);
    844         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)__Stack32ToFlat(&params));
     844        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)&params);
    845845        if(ret != 0) {
    846846                rprintf(("invalid number of frame bits %d\n", pHwParams->ulBitsPerSample*pHwParams->ulNumChannels));
     
    859859        _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_RATE,
    860860                                                  pHwParams->ulSampleRate, 0);
    861         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)__Stack32ToFlat(&params));
     861        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)&params);
    862862        if(ret != 0) {
    863863                rprintf(("32_WSetHwPms (first pass) error %d bps:%d fmt: %d ch: %d sr: %d\n",
     
    878878                                _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_RATE,
    879879                                                                          pHwParams->ulSampleRate, 0);
    880                                 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)__Stack32ToFlat(&params));
     880                                ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)&params);
    881881                                if(ret == 0)
    882882                                {
     
    892892                                        _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_RATE,
    893893                                                                                  pHwParams->ulSampleRate, 0);
    894                                         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)__Stack32ToFlat(&params));
     894                                        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_HW_REFINE, (ULONG)&params);
    895895                                        goto __next;
    896896                                }
     
    10001000                         pHwParams->ulSampleRate, pHwParams->ulBitsPerSample, pHwParams->ulNumChannels, periodsize, nrperiods));
    10011001
    1002         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_HW_PARAMS, (ULONG)__Stack32ToFlat(&params));
     1002        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_HW_PARAMS, (ULONG)&params);
    10031003        if (ret == -77 && fTryAgain == FALSE)
    10041004        {
    1005                 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0);
     1005                ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0);
    10061006                fTryAgain = TRUE;
    10071007                rprintf((" Error -77 from first IOCTL HW Parms"));
     
    10451045                swparams.xfer_align        = periodsize;
    10461046
    1047                 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_SW_PARAMS, (ULONG)__Stack32ToFlat(&swparams));
     1047                ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_SW_PARAMS, (ULONG)&swparams);
    10481048        }
    10491049
    10501050        total = 0;
    10511051        per_bytes = periodbytes;
    1052         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)__Stack32ToFlat(&status));
     1052        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)&status);
    10531053        if ( ((status.state != SNDRV_PCM_STATE_PREPARED) &&
    10541054                   (status.state != SNDRV_PCM_STATE_SETUP) &&
     
    10561056                   (status.state != SNDRV_PCM_STATE_DRAINING))) {
    10571057                rprintf(("Device is not in proper state: %lx. Calling prepare\n", status.state));
    1058                 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0);
     1058                ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0);
    10591059        }
    10601060        return UNIXToOSSError(ret);
     
    10941094
    10951095        /* get the status of the circular dma buffer */
    1096         iRet = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)__Stack32ToFlat(&status));
     1096        iRet = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)&status);
    10971097
    10981098        if(iRet) {
     
    11261126                if (status.state == SNDRV_PCM_STATE_XRUN) {
    11271127                        rprintf(("Internal Error: Xrun"));
    1128                         iRet = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0);
     1128                        iRet = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0);
    11291129                        if (iRet < 0) {
    11301130                                rprintf(("Prepare failed: state=%x avail=%x ReqSize=%x", status.state, status.avail, ulReqSize));
    11311131                                return UNIXToOSSError(iRet);
    11321132                        }
    1133                         iRet = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)__Stack32ToFlat(&status));
     1133                        iRet = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)&status);
    11341134                        rprintf(("Xrun restarted: state=%x avail=%x ReqSize=%x", status.state, status.avail, ulReqSize));
    11351135                        if (iRet < 0) return UNIXToOSSError(iRet);
     
    11651165                while (ulSize && ulJ && iRet) {
    11661166                        for (ulI=0; ulI < 1000; ulI++) {
    1167                                 iRet1 = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)__Stack32ToFlat(&status));
     1167                                iRet1 = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)&status);
    11681168                                // If here any state and have free buffer to any byte
    11691169                                if ((status.state != SNDRV_PCM_STATE_XRUN ) && samples_to_bytes(status.avail) ) break;
     
    11731173                                if (ulI > 998) {
    11741174                                        rprintf(("timeout state=%x avail=%d hw=%d app=%d",status.state,samples_to_bytes(status.avail),samples_to_bytes(status.hw_ptr), samples_to_bytes(status.appl_ptr)));
    1175                                         iRet1 = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0);
     1175                                        iRet1 = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0);
    11761176                                }
    11771177                        }
     
    11901190                                if ( iRet != -11 ) {
    11911191                                        rprintf(("Doing prepare"));
    1192                                         iRet1 = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0);
     1192                                        iRet1 = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0);
    11931193                                }
    11941194                                continue;
     
    12311231//        {
    12321232//                printk("warning: ulTransferred [%d] less than requested [%d]", *pulTransferred, ulSize);
    1233 //                iRet1 = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0);
     1233//                iRet1 = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0);
    12341234//        }
    12351235
     
    12571257
    12581258        //Get the status of the stream
    1259         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)__Stack32ToFlat(&status));
     1259        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)&status);
    12601260
    12611261        if(ret) {
     
    12891289
    12901290        //Get the nr of bytes left in the audio buffer
    1291         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)__Stack32ToFlat(&status));
     1291        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)&status);
    12921292
    12931293        if(ret) {
     
    13211321
    13221322        //Get the status of the stream
    1323         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)__Stack32ToFlat(&status));
     1323        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)&status);
    13241324
    13251325        if(ret) {
     
    13521352
    13531353        //Get the status of the stream
    1354         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)__Stack32ToFlat(&status));
     1354        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)&status);
    13551355        if(ret) return UNIXToOSSError(ret);
    13561356        *pStatus = status.state;
     
    13841384
    13851385        dprintf(("OSS32_WaveSetVolume %x to (%d,%d)", streamid, leftvol, rightvol));
    1386         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_SETVOLUME, (ULONG)__Stack32ToFlat(&pcm_volume));
     1386        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_PCM_IOCTL_SETVOLUME, (ULONG)&pcm_volume);
    13871387        return UNIXToOSSError(ret);
    13881388}
  • GPL/trunk/lib32/soundmidi.c

    r598 r679  
    120120    {
    121121        //get the client id
    122         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_SEQ_IOCTL_CLIENT_ID, (ULONG)&pHandle->clientid);
     122        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_SEQ_IOCTL_CLIENT_ID, (ULONG)&pHandle->clientid);
    123123        if(ret) {
    124124            rprintf(("Get client id failed with error %d", ret));
     
    130130        for(i=64;i<64+((deviceid+1)<<3);i++)
    131131        {
    132             memset((PVOID)__Stack32ToFlat(&clientinfo), 0, sizeof(clientinfo));
     132            memset(&clientinfo, 0, sizeof(clientinfo));
    133133            clientinfo.client = i;
    134134            clientinfo.type   = KERNEL_CLIENT;
    135             ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_SEQ_IOCTL_GET_CLIENT_INFO, (ULONG)__Stack32ToFlat(&clientinfo));
     135            ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_SEQ_IOCTL_GET_CLIENT_INFO, (ULONG)&clientinfo);
    136136            if(ret) {
    137137                continue;
     
    157157        portinfo.addr.client = pHandle->clientid;
    158158        portinfo.flags       = SNDRV_SEQ_PORT_TYPE_APPLICATION;
    159         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_SEQ_IOCTL_CREATE_PORT, (ULONG)__Stack32ToFlat(&portinfo));
     159        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_SEQ_IOCTL_CREATE_PORT, (ULONG)&portinfo);
    160160        if(ret) {
    161161            rprintf(("subscribe error %d", ret));
     
    172172        subs.sender.client = pHandle->clientid;
    173173        subs.sender.port   = pHandle->clientport;
    174         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_SEQ_IOCTL_SUBSCRIBE_PORT, (ULONG)__Stack32ToFlat(&subs));
     174        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_SEQ_IOCTL_SUBSCRIBE_PORT, (ULONG)&subs);
    175175        if(ret) {
    176176            rprintf(("subscribe error %d", ret));
     
    212212        subs.sender.client = pHandle->clientid;
    213213        subs.sender.port   = pHandle->clientport;
    214         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_SEQ_IOCTL_UNSUBSCRIBE_PORT, (ULONG)__Stack32ToFlat(&subs));
     214        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_SEQ_IOCTL_UNSUBSCRIBE_PORT, (ULONG)&subs);
    215215        if(ret) {
    216216            rprintf(("unsubscribe error %d", ret));
     
    227227        portinfo.addr.client = pHandle->clientid;
    228228        portinfo.addr.port   = pHandle->clientport;
    229         ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_SEQ_IOCTL_DELETE_PORT, (ULONG)__Stack32ToFlat(&portinfo));
     229        ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_SEQ_IOCTL_DELETE_PORT, (ULONG)&portinfo);
    230230        if(ret) {
    231231            dprintf(("delete port error %d", ret));
     
    300300    pHandle->file.f_flags = O_NONBLOCK;
    301301
    302     memset((PVOID)__Stack32ToFlat(&fmevent), 0, sizeof(fmevent));
     302    memset(&fmevent, 0, sizeof(fmevent));
    303303    switch(Cmd) {
    304304    case IDC32_MIDI_NOTEON:
     
    331331    fmevent.dest.port     = pHandle->destport;
    332332
    333     transferred = pHandle->file.f_op->write(&pHandle->file, (char *)__Stack32ToFlat(&fmevent), sizeof(fmevent), &pHandle->file.f_pos);
     333    transferred = pHandle->file.f_op->write(&pHandle->file, (char *)&fmevent, sizeof(fmevent), &pHandle->file.f_pos);
    334334
    335335    if(transferred < 0) {
  • GPL/trunk/lib32/soundmixer.c

    r604 r679  
    148148  }
    149149  //retrieve mixer information
    150   ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file,
     150  ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file,
    151151                  SNDRV_CTL_IOCTL_CARD_INFO,
    152152                  (ULONG)&pHandle->info);
     
    157157  pHandle->list.offset = 0;
    158158  pHandle->list.space  = 0;
    159   ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file,
     159  ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file,
    160160                  SNDRV_CTL_IOCTL_ELEM_LIST,
    161161                  (ULONG)&pHandle->list);
     
    172172  pHandle->list.space  = pHandle->list.count;
    173173  pHandle->list.pids   = pHandle->pids;
    174   ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file,
     174  ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file,
    175175                  SNDRV_CTL_IOCTL_ELEM_LIST,
    176176                  (ULONG)&pHandle->list);
     
    271271      pElemInfo->value.enumerated.item = i;
    272272      pElemInfo->id.numid = pHandle->pids[idx].numid;
    273       ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_INFO, (ULONG)pElemInfo);
     273      ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_CTL_IOCTL_ELEM_INFO, (ULONG)pElemInfo);
    274274      if(ret) {
    275275        DebugInt3();
     
    484484    pElem->value.integer.value[0] = TRUE;  //switch, not mute control (inversed)
    485485    pElem->value.integer.value[1] = TRUE;
    486     ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_WRITE, (ULONG)pElem);
     486    ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_CTL_IOCTL_ELEM_WRITE, (ULONG)pElem);
    487487  }
    488488  //request information about mixer control
    489489  pElemInfo->id.numid = pHandle->pids[idx].numid;
    490   ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_INFO, (ULONG)pElemInfo);
     490  ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_CTL_IOCTL_ELEM_INFO, (ULONG)pElemInfo);
    491491  if(ret) {
    492492    ret = UNIXToOSSError(ret);
     
    515515
    516516#if 1
    517   ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_WRITE, (ULONG)pElem);
     517  ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_CTL_IOCTL_ELEM_WRITE, (ULONG)pElem);
    518518#else
    519519  // looking for more, then one opened streams to prevent of muting active stream
     
    528528  {
    529529    dprintf(("OSS32_MixSetVolume Ioctl"));
    530     ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_WRITE, (ULONG)pElem);
     530    ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_CTL_IOCTL_ELEM_WRITE, (ULONG)pElem);
    531531
    532532    if(idxMute != -1 && volume == 0) {
     
    538538      pElem->value.integer.value[1] = FALSE;
    539539      dprintf(("OSS32_MixSetVolume Ioctl mute"));
    540       ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_WRITE, (ULONG)pElem);
     540      ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_CTL_IOCTL_ELEM_WRITE, (ULONG)pElem);
    541541    }
    542542  }
     
    603603          //request information about mixer control
    604604          pElemInfo->id.numid       = pHandle->pids[idx].numid;
    605           ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_INFO, (ULONG)pElemInfo);
     605          ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_CTL_IOCTL_ELEM_INFO, (ULONG)pElemInfo);
    606606          if(ret) {
    607607            ret = UNIXToOSSError(ret);
     
    621621          }
    622622
    623           ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_WRITE, (ULONG)pElem);
     623          ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_CTL_IOCTL_ELEM_WRITE, (ULONG)pElem);
    624624          if(ret) {
    625625            ret = UNIXToOSSError(ret);
     
    631631      //request information about mixer control
    632632      pElemInfo->id.numid = pHandle->pids[idx].numid;
    633       ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_INFO, (ULONG)pElemInfo);
     633      ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_CTL_IOCTL_ELEM_INFO, (ULONG)pElemInfo);
    634634      if(ret) {
    635635        ret = UNIXToOSSError(ret);
     
    678678    //request information about mixer control
    679679    pElemInfo->id.numid = pHandle->pids[idx].numid;
    680     ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_INFO, (ULONG)pElemInfo);
     680    ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_CTL_IOCTL_ELEM_INFO, (ULONG)pElemInfo);
    681681    if(ret) {
    682682      ret = UNIXToOSSError(ret);
     
    707707
    708708  dprintf(("OSS32_MixSetProperty of %s to %x", pHandle->pids[idx].name, ulValue));
    709   ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_CTL_IOCTL_ELEM_WRITE, (ULONG)pElem);
     709  ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file, SNDRV_CTL_IOCTL_ELEM_WRITE, (ULONG)pElem);
    710710
    711711  kfree(pElem);
     
    849849  }
    850850  //retrieve mixer information
    851   ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file,
     851  ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file,
    852852                  SNDRV_CTL_IOCTL_CARD_INFO,
    853853                  (ULONG)&pHandle->info);
     
    911911  }
    912912  //retrieve mixer information
    913   ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file,
     913  ret = pHandle->file.f_op->unlocked_ioctl(&pHandle->file,
    914914                  SNDRV_CTL_IOCTL_CARD_INFO,
    915915                  (ULONG)&pHandle->info);
  • GPL/trunk/lib32/soundoss.h

    r305 r679  
    6969} mixerhandle;
    7070
    71 extern struct file_operations *alsa_fops;
     71extern const struct file_operations *alsa_fops;
    7272extern int                     nrCardsDetected;
    7373
  • GPL/trunk/lib32/task.c

    r479 r679  
    2626#include <linux/kernel.h>
    2727#include <linux/fs.h>
    28 #include <linux/tqueue.h>
    2928#include <linux/interrupt.h>
    3029#define LINUX
  • GPL/trunk/lib32/timer.c

    r445 r679  
    3030#include <asm/io.h>
    3131#include <linux/time.h>
     32#include <linux/math64.h>
     33#include <linux/clocksource.h>
    3234
    3335#define LINUX
     
    3638#include <dbgos2.h>
    3739
     40#pragma pack(1)
     41#include     "infoseg.h"
     42#pragma pack()
     43extern PVOID  KernSISData;
     44#define KernSISData             ((struct InfoSegGDT *)&KernSISData)
     45
    3846static   long          jiffiems    = 1000/HZ;
    3947static   long          lasttime    = 0;
     
    4755    long delta, newtime, remainder;
    4856
    49     newtime    = os2gettimemsec();
     57    newtime    = KernSISData->SIS_MsCount;
    5058    delta      = newtime - lasttime;
    5159
     
    95103{
    96104#if 0
    97     tv->tv_sec  = 0; //os2gettimesec();
    98     tv->tv_usec = os2gettimemsec() * 1000;
     105    tv->tv_sec  = 0; //KernSISData->SIS_BigTime;
     106    tv->tv_usec = KernSISData->SIS_MsCount * 1000;
    99107#else /* r.ihle patch */
    100     unsigned u = os2gettimemsec();
     108    unsigned u = KernSISData->SIS_MsCount;
    101109    tv->tv_sec  = u / 1000;
    102110    tv->tv_usec = (u % 1000) * 1000;
     
    140148//******************************************************************************
    141149//******************************************************************************
     150
     151/**
     152 * ns_to_timespec - Convert nanoseconds to timespec
     153 * @nsec:       the nanoseconds value to be converted
     154 *
     155 * Returns the timespec representation of the nsec parameter.
     156 */
     157struct timespec ns_to_timespec(const s64 nsec)
     158{
     159        struct timespec ts;
     160        s32 rem;
     161
     162        if (!nsec) {
     163                ts.tv_sec = 0;
     164                ts.tv_nsec = 0;
     165                return ts;
     166        }
     167
     168        ts.tv_sec = div_s64_rem(nsec, NSEC_PER_SEC, &rem);
     169        if (unlikely(rem < 0)) {
     170                ts.tv_sec--;
     171                rem += NSEC_PER_SEC;
     172        }
     173        ts.tv_nsec = rem;
     174
     175        return ts;
     176}
     177
     178
     179//******************************************************************************
     180//******************************************************************************
     181
     182/**
     183 * ns_to_timespec - Convert nanoseconds to timespec
     184 * @nsec:       the nanoseconds value to be converted
     185 *
     186 * Returns the timespec representation of the nsec parameter.
     187 */
     188struct timespec64 ns_to_timespec64(const s64 nsec)
     189{
     190        struct timespec64 ts;
     191        s32 rem;
     192
     193        if (!nsec) {
     194                ts.tv_sec = 0;
     195                ts.tv_nsec = 0;
     196                return ts;
     197        }
     198
     199        ts.tv_sec = div_s64_rem(nsec, NSEC_PER_SEC, &rem);
     200        if (unlikely(rem < 0)) {
     201                ts.tv_sec--;
     202                rem += NSEC_PER_SEC;
     203        }
     204        ts.tv_nsec = rem;
     205
     206        return ts;
     207}
     208//******************************************************************************
     209//******************************************************************************
     210
     211void timecounter_init(struct timecounter *tc,
     212                      const struct cyclecounter *cc,
     213                      u64 start_tstamp)
     214{
     215        tc->cc = cc;
     216        tc->cycle_last = cc->read(cc);
     217        tc->nsec = start_tstamp;
     218}
     219
     220/**
     221 * timecounter_read_delta - get nanoseconds since last call of this function
     222 * @tc:         Pointer to time counter
     223 *
     224 * When the underlying cycle counter runs over, this will be handled
     225 * correctly as long as it does not run over more than once between
     226 * calls.
     227 *
     228 * The first call to this function for a new time counter initializes
     229 * the time tracking and returns an undefined result.
     230 */
     231static u64 timecounter_read_delta(struct timecounter *tc)
     232{
     233        cycle_t cycle_now, cycle_delta;
     234        u64 ns_offset;
     235
     236        /* read cycle counter: */
     237        cycle_now = tc->cc->read(tc->cc);
     238
     239        /* calculate the delta since the last timecounter_read_delta(): */
     240        cycle_delta = (cycle_now - tc->cycle_last) & tc->cc->mask;
     241
     242        /* convert to nanoseconds: */
     243        ns_offset = cyclecounter_cyc2ns(tc->cc, cycle_delta);
     244
     245        /* update time stamp of timecounter_read_delta() call: */
     246        tc->cycle_last = cycle_now;
     247
     248        return ns_offset;
     249}
     250
     251u64 timecounter_read(struct timecounter *tc)
     252{
     253        u64 nsec;
     254
     255        /* increment time by nanoseconds since last call */
     256        nsec = timecounter_read_delta(tc);
     257        nsec += tc->nsec;
     258        tc->nsec = nsec;
     259
     260        return nsec;
     261}
     262
     263/**
     264 * set_normalized_timespec - set timespec sec and nsec parts and normalize
     265 *
     266 * @ts:         pointer to timespec variable to be set
     267 * @sec:        seconds to set
     268 * @nsec:       nanoseconds to set
     269 *
     270 * Set seconds and nanoseconds field of a timespec variable and
     271 * normalize to the timespec storage format
     272 *
     273 * Note: The tv_nsec part is always in the range of
     274 *      0 <= tv_nsec < NSEC_PER_SEC
     275 * For negative values only the tv_sec field is negative !
     276 */
     277void set_normalized_timespec64(struct timespec64 *ts, time64_t sec, s64 nsec)
     278{
     279        while (nsec >= NSEC_PER_SEC) {
     280                /*
     281                 * The following asm() prevents the compiler from
     282                 * optimising this loop into a modulo operation. See
     283                 * also __iter_div_u64_rem() in include/linux/time.h
     284                 */
     285//              asm("" : "+rm"(nsec));
     286                nsec -= NSEC_PER_SEC;
     287                ++sec;
     288        }
     289        while (nsec < 0) {
     290//              asm("" : "+rm"(nsec));
     291                nsec += NSEC_PER_SEC;
     292                --sec;
     293        }
     294        ts->tv_sec = sec;
     295        ts->tv_nsec = nsec;
     296}
  • GPL/trunk/lib32/waitqueue.c

    r32 r679  
    3838//******************************************************************************
    3939//******************************************************************************
    40 void add_wait_queue(wait_queue_head_t *q, wait_queue_t * wait)
     40void add_wait_queue(struct wait_queue_head *q, struct wait_queue_entry * wait)
    4141{
    4242//    dprintf3(("WARNING: add_wait_queue STUB"));
     
    4444//******************************************************************************
    4545//******************************************************************************
    46 void add_wait_queue_exclusive(wait_queue_head_t *q)
     46void add_wait_queue_exclusive(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry)
    4747{
    4848//    dprintf3(("WARNING: add_wait_queue_exclusive STUB"));
     
    5050//******************************************************************************
    5151//******************************************************************************
    52 void remove_wait_queue(wait_queue_head_t *q, wait_queue_t * wait)
     52void remove_wait_queue(struct wait_queue_head *q, struct wait_queue_entry * wait)
    5353{
    5454//    dprintf(("WARNING: remove_wait_queue STUB"));
     
    7575//******************************************************************************
    7676//******************************************************************************
    77 void init_waitqueue_entry(wait_queue_t *q, struct task_struct *p)
     77void init_waitqueue_entry(struct wait_queue_entry *wq_entry, struct task_struct *p)
    7878{
    7979//    dprintf(("WARNING: init_waitqueue_entry STUB"));
     
    8888//******************************************************************************
    8989//******************************************************************************
     90/**
     91 * complete: - signals a single thread waiting on this completion
     92 * @x:  holds the state of this particular completion
     93 *
     94 * This will wake up a single thread waiting on this completion. Threads will be
     95 * awakened in the same order in which they were queued.
     96 *
     97 * See also complete_all(), wait_for_completion() and related routines.
     98 *
     99 * It may be assumed that this function implies a write memory barrier before
     100 * changing the task state if and only if any tasks are woken up.
     101 */
     102void complete(struct completion *x)
     103{
     104        unsigned long flags;
     105
     106        spin_lock_irqsave(&x->wait.lock, flags);
     107        x->done++;
     108        __wake_up_locked(&x->wait, TASK_NORMAL, 1);
     109        spin_unlock_irqrestore(&x->wait.lock, flags);
     110}
     111/**
     112 * complete_all: - signals all threads waiting on this completion
     113 * @x:  holds the state of this particular completion
     114 *
     115 * This will wake up all threads waiting on this particular completion event.
     116 *
     117 * If this function wakes up a task, it executes a full memory barrier before
     118 * accessing the task state.
     119 *
     120 * Since complete_all() sets the completion of @x permanently to done
     121 * to allow multiple waiters to finish, a call to reinit_completion()
     122 * must be used on @x if @x is to be used again. The code must make
     123 * sure that all waiters have woken and finished before reinitializing
     124 * @x. Also note that the function completion_done() can not be used
     125 * to know if there are still waiters after complete_all() has been called.
     126 */
     127void complete_all(struct completion *x)
     128{
     129        unsigned long flags;
     130
     131        spin_lock_irqsave(&x->wait.lock, flags);
     132        __wake_up_locked(&x->wait, TASK_NORMAL, 1);
     133        spin_unlock_irqrestore(&x->wait.lock, flags);
     134}
     135//******************************************************************************
     136//******************************************************************************
     137void __wake_up_locked(wait_queue_head_t *q, unsigned int mode, int nr)
     138{
     139    dprintf3(("WARNING: __wake_up_locked STUB"));
     140}
     141//******************************************************************************
     142//******************************************************************************
     143/**
     144 * wait_for_completion: - waits for completion of a task
     145 * @x:  holds the state of this particular completion
     146 *
     147 * This waits to be signaled for completion of a specific task. It is NOT
     148 * interruptible and there is no timeout.
     149 *
     150 * See also similar routines (i.e. wait_for_completion_timeout()) with timeout
     151 * and interrupt capability. Also see complete().
     152 */
     153void wait_for_completion(struct completion *x)
     154{
     155    dprintf3(("WARNING: wait_for_completion STUB"));
     156}
     157
     158
     159/**
     160 * wait_for_completion_timeout: - waits for completion of a task (w/timeout)
     161 * @x:  holds the state of this particular completion
     162 * @timeout:  timeout value in jiffies
     163 *
     164 * This waits for either a completion of a specific task to be signaled or for a
     165 * specified timeout to expire. The timeout is in jiffies. It is not
     166 * interruptible.
     167 *
     168 * Return: 0 if timed out, and positive (at least 1, or number of jiffies left
     169 * till timeout) if completed.
     170 */
     171unsigned long wait_for_completion_timeout(struct completion *x, unsigned long timeout)
     172{
     173    dprintf3(("WARNING: wait_for_completion_timeout STUB"));
     174    return 1;
     175}
Note: See TracChangeset for help on using the changeset viewer.