[haiku-commits] r36993 - haiku/branches/developer/siarzhuk/sis7018

  • From: zharik@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 1 Jun 2010 20:56:56 +0200 (CEST)

Author: siarzhuk
Date: 2010-06-01 20:56:55 +0200 (Tue, 01 Jun 2010)
New Revision: 36993
Changeset: http://dev.haiku-os.org/changeset/36993/haiku

Modified:
   haiku/branches/developer/siarzhuk/sis7018/AC97.cpp
   haiku/branches/developer/siarzhuk/sis7018/AC97.h
   haiku/branches/developer/siarzhuk/sis7018/Device.cpp
   haiku/branches/developer/siarzhuk/sis7018/Device.h
   haiku/branches/developer/siarzhuk/sis7018/Driver.cpp
   haiku/branches/developer/siarzhuk/sis7018/Driver.h
   haiku/branches/developer/siarzhuk/sis7018/Registers.h
   haiku/branches/developer/siarzhuk/sis7018/Settings.cpp
   haiku/branches/developer/siarzhuk/sis7018/Settings.h
   haiku/branches/developer/siarzhuk/sis7018/Stream.cpp
   haiku/branches/developer/siarzhuk/sis7018/Stream.h
Log:
Fixed Haiku coding style violations mostly pointed by FuncHaikuCheck vim script.


Modified: haiku/branches/developer/siarzhuk/sis7018/AC97.cpp
===================================================================
--- haiku/branches/developer/siarzhuk/sis7018/AC97.cpp  2010-06-01 18:55:37 UTC 
(rev 36992)
+++ haiku/branches/developer/siarzhuk/sis7018/AC97.cpp  2010-06-01 18:56:55 UTC 
(rev 36993)
@@ -1,11 +1,12 @@
 /*
- *     SiS 7018 Audio Driver.
- *     Copyright (c) 2002, 2008, 2009 S.Zharski <imker@xxxxxx>
+ *     SiS 7018, Trident 4D Wave DX/NX, Acer Lab M5451 Sound Driver.
+ *     Copyright (c) 2002, 2008 S.Zharski <imker@xxxxxx>
  *     Distributed under the terms of the MIT license.
  *
  */
 
 #include "AC97.h"
+
 #include "Driver.h"
 #include "Settings.h"
 
@@ -215,8 +216,8 @@
 
 
 #define TRACE_CAPABILITIES(__capabilites, __array)\
-       for(size_t i = 0; i < _countof(__array); i++) {\
-               if((__capabilites & __array[i].Mask) == __array[i].Mask) {\
+       for (size_t i = 0; i < _countof(__array); i++) {\
+               if ((__capabilites & __array[i].Mask) == __array[i].Mask) {\
                        TRACE("\t%s;\n", __array[i].Description);\
                }\
        }\
@@ -227,26 +228,26 @@
 {
        // reset codec.
        fCDC->WriteCodec(AC97Reset, 0x0000);
-       for(size_t i = 0; i < 500; i++) {
-               if((fCDC->ReadCodec(AC97Powerdown) & 0xf) == 0xf)
+       for (size_t i = 0; i < 500; i++) {
+               if ((fCDC->ReadCodec(AC97Powerdown) & 0xf) == 0xf)
                        break;
                snooze(1000);
        }
 
        // obtain codec information and capabilities.
-       fId = (fCDC->ReadCodec(AC97VendorID1) << 16) | 
+       fId = (fCDC->ReadCodec(AC97VendorID1) << 16) |
                                        fCDC->ReadCodec(AC97VendorID2);
        size_t cdcIndex = 0;
-       for(; cdcIndex < _countof(KnownCodecs) - 1; cdcIndex++) {
-               if(fId == KnownCodecs[cdcIndex].Id) {
-                       TRACE("%s codec [%#010x] found.\n", 
+       for (; cdcIndex < _countof(KnownCodecs) - 1; cdcIndex++) {
+               if (fId == KnownCodecs[cdcIndex].Id) {
+                       TRACE("%s codec [%#010x] found.\n",
                                                                                
KnownCodecs[cdcIndex].Name, fId);
                        break;
                }
        }
 
-       if(cdcIndex == _countof(KnownCodecs)) {
-               TRACE_ALWAYS("%s codec [%#010x] found.\n", 
+       if (cdcIndex == _countof(KnownCodecs)) {
+               TRACE_ALWAYS("%s codec [%#010x] found.\n",
                                                                                
KnownCodecs[cdcIndex].Name, fId);
        }
 
@@ -261,12 +262,12 @@
        TRACE("Ext.Capabilities:%#06x:\n", fExtCapabilities);
        TRACE_CAPABILITIES(fExtCapabilities, ExtCapabilities);
        
-       TRACE("Stereo 3D Enhancement:%s\n", 
+       TRACE("Stereo 3D Enhancement:%s\n",
                                Stereo3DEnhancement[(status & 0x7c00) >> 10]);
 
        // set mixer defaults and enable line out sources
-       fCDC->WriteCodec(AC97CenterLFEVolume,   0x0000); // 0 dB  
-       fCDC->WriteCodec(AC97SurroundVolume,    0x0000); // 0 dB  
+       fCDC->WriteCodec(AC97CenterLFEVolume,   0x0000); // 0 dB
+       fCDC->WriteCodec(AC97SurroundVolume,    0x0000); // 0 dB
        fCDC->WriteCodec(AC97MasterVolume,              0x0000); // 0 dB
        fCDC->WriteCodec(AC97AUXOutVolume,              0x0000); // 0 dB
        fCDC->WriteCodec(AC97MonoVolume,                0x0000); // 0 dB
@@ -274,7 +275,7 @@
        fCDC->WriteCodec(AC97CDVolume,                  0x0808); // enable CD in
        fCDC->WriteCodec(AC97LineInVolume,              0x0808); // enable line 
in
 
-       fCDC->WriteCodec(AC97RecordSelect,              0x0404); //   
+       fCDC->WriteCodec(AC97RecordSelect,              0x0404); //
 
        fStatus = B_OK;
 
@@ -284,14 +285,14 @@
 status_t
 AC97::InitCheck()
 {
-       if(fCDC == NULL)
+       if (fCDC == NULL)
                return B_NO_INIT;
        
        return fStatus;
 }
 
 // Control ids are encoded in the following way:
-// GGBBRRTT -- 
+// GGBBRRTT --
 //                     GG - 10th of granularity. signed!
 //                     BB - base level - correspond to 0 db
 //                     RR - AC97 Register handled by this control
@@ -299,9 +300,9 @@
 
 
 enum MIXControlTypes {
-       MIX_Gain        = 0x01, 
+       MIX_Gain        = 0x01,
        MIX_RGain       = 0x12, // 0x02 is assumed as reserved - used for right 
chanel in stereo
-       MIX_Stereo      = 0x10, // this is the bug in Haiku multimedia stereo 
controls 
+       MIX_Stereo      = 0x10, // this is the bug in Haiku multimedia stereo 
controls
        MIX_Mute        = 0x04, //               return incremented but real 
assigned id!!!!
        MIX_Boost       = 0x08,
        MIX_MUX         = 0x20,
@@ -310,20 +311,20 @@
 };
 
 
-struct GainInfo  {
-  uint8 fOff;  // offset of mask in register word
-  uint8 fBase; // base - default value of register
-  uint8 fMask; // mask -  maximal value of register
-  float fMult; // multiplier - bits to dB recalculate
+struct GainInfo {
+       uint8 fOff;             // offset of mask in register word
+       uint8 fBase;    // base - default value of register
+       uint8 fMask;    // mask - maximal value of register
+       float fMult;    // multiplier - bits to dB recalculate
 };
 
 
-GainInfo MixGain  = { 0x00, 0x00, 0x3f, -1.5 }; // 0x3f???
-GainInfo InGain   = { 0x00, 0x08, 0x1f, -1.5 };
-GainInfo RecGain  = { 0x00, 0x00, 0x0f,  1.5 };
-GainInfo BeepGain = { 0x01, 0x00, 0x1e,  3.0 };
-GainInfo ToneGain = { 0x00, 0x07, 0x0f, -1.5 };
-GainInfo C3DGain  = { 0x00, 0x00, 0x0f,  1.0 };
+GainInfo MixGain       = { 0x00, 0x00, 0x3f, -1.5 }; // 0x3f???
+GainInfo InGain                = { 0x00, 0x08, 0x1f, -1.5 };
+GainInfo RecGain       = { 0x00, 0x00, 0x0f,  1.5 };
+GainInfo BeepGain      = { 0x01, 0x00, 0x1e,  3.0 };
+GainInfo ToneGain      = { 0x00, 0x07, 0x0f, -1.5 };
+GainInfo C3DGain       = { 0x00, 0x00, 0x0f,  1.0 };
 
 
 struct MIXControlInfo {
@@ -371,7 +372,7 @@
 InitGainLimits(multi_mix_control& Control, GainInfo& Info)
 {
        float base = Info.fBase >> Info.fOff;
-       float max  = Info.fMask >> Info.fOff;
+       float max = Info.fMask >> Info.fOff;
        
        float min_gain = Info.fMult * (0.0 - base);
        float max_gain = Info.fMult * (max - base);
@@ -386,9 +387,9 @@
        Control.id |= (Info.fBase << 16);
 
        TRACE_ALWAYS("base:%#04x; mask:%#04x; mult:%f\n", Info.fBase, 
Info.fMask, Info.fMult);
-       TRACE_ALWAYS("  min:%f; max:%f; gran:%f -> %#010x\n", 
-                               Control.gain.min_gain, 
-                               Control.gain.max_gain, 
+       TRACE_ALWAYS(" min:%f; max:%f; gran:%f -> %#010x\n",
+                               Control.gain.min_gain,
+                               Control.gain.max_gain,
                                Control.gain.granularity, Control.id);
 }
 
@@ -397,21 +398,21 @@
        { "Record Gain",        AC97RecordGain, 
MIX_Gain|MIX_Stereo|MIX_Mute|MIX_MUX, &RecGain }
 };
 
-int32 CreateMIXControlGroup(multi_mix_control_info* MultiInfo, int32& index, 
+int32 CreateMIXControlGroup(multi_mix_control_info* MultiInfo, int32& index,
                                                                        int32 
parentIndex, MIXControlInfo& Info)
 {
-       int32  IdReg = Info.fAC97Reg << 8;
+       int32 IdReg = Info.fAC97Reg << 8;
 //     int32 &index = MultiInfo->control_count;
        multi_mix_control* Controls = MultiInfo->controls;
        
-       int32 groupIndex =
-       Controls[index].id              = IdReg | MIX_Group;
-       Controls[index].flags   = B_MULTI_MIX_GROUP;
-       Controls[index].parent  = parentIndex;
+       int32 groupIndex
+               = Controls[index].id    = IdReg | MIX_Group;
+       Controls[index].flags           = B_MULTI_MIX_GROUP;
+       Controls[index].parent          = parentIndex;
        strncpy(Controls[index].name, Info.fName, sizeof(Controls[index].name));
        index++;
        
-       if(Info.fType & MIX_Mute) {
+       if (Info.fType & MIX_Mute) {
                Controls[index].id              = IdReg | MIX_Mute;
                Controls[index].flags   = B_MULTI_MIX_ENABLE;
                Controls[index].parent  = groupIndex;
@@ -420,7 +421,7 @@
        }
 
        int32 gainIndex = 0;
-       if(Info.fType & MIX_Gain) {
+       if (Info.fType & MIX_Gain) {
                Controls[index].id              = IdReg | MIX_Gain;
                Controls[index].id              |= (Info.fType & MIX_Stereo);
                Controls[index].flags   = B_MULTI_MIX_GAIN;
@@ -431,7 +432,7 @@
                index++;
        }
 
-       if(Info.fType & MIX_Stereo) {
+       if (Info.fType & MIX_Stereo) {
                Controls[index].id              = IdReg | MIX_RGain;
                Controls[index].flags   = B_MULTI_MIX_GAIN;
                Controls[index].parent  = groupIndex;
@@ -441,7 +442,7 @@
                index++;
        }
 
-       if(Info.fType & MIX_Boost) {
+       if (Info.fType & MIX_Boost) {
                Controls[index].id              = IdReg | MIX_Boost;
                Controls[index].flags   = B_MULTI_MIX_ENABLE;
                Controls[index].parent  = groupIndex;
@@ -450,16 +451,16 @@
                index++;
        }
 
-       if(Info.fType & MIX_MUX) {
-               int32 recordMUX = 
-               Controls[index].id              = IdReg | MIX_MUX;
-               Controls[index].flags   = B_MULTI_MIX_MUX;
-               Controls[index].parent  = groupIndex;
-               Controls[index].string  = S_null;
+       if (Info.fType & MIX_MUX) {
+               int32 recordMUX
+                       = Controls[index].id    = IdReg | MIX_MUX;
+               Controls[index].flags           = B_MULTI_MIX_MUX;
+               Controls[index].parent          = groupIndex;
+               Controls[index].string          = S_null;
                strncpy(Controls[index].name, "Source", 
sizeof(Controls[index].name));
                index++;
 
-               for(size_t i = 0; i < _countof(RecordSources); i++) {
+               for (size_t i = 0; i < _countof(RecordSources); i++) {
                        Controls[index].id              = IdReg | (i << 24);
                        Controls[index].flags   = B_MULTI_MIX_MUX_VALUE;
                        Controls[index].master  = 0;
@@ -478,36 +479,36 @@
 {
        int32 index = 0;
        multi_mix_control* Controls = Info->controls;
-       int32 mixerGroup        = 
-       Controls[index].id              = 0x8000; // 0x80 - is not a valid AC97 
register
-       Controls[index].flags   = B_MULTI_MIX_GROUP;
-       Controls[index].parent  = 0;
+       int32 mixerGroup        
+               = Controls[index].id    = 0x8000; // 0x80 - is not a valid AC97 
register
+       Controls[index].flags           = B_MULTI_MIX_GROUP;
+       Controls[index].parent          = 0;
        strncpy(Controls[index].name, "AC97 Mixer", 
sizeof(Controls[index].name));
        index++;
 
-       for(size_t i = 0; i < _countof(MIXControls); i++) {
+       for (size_t i = 0; i < _countof(MIXControls); i++) {
                CreateMIXControlGroup(Info, index, mixerGroup, MIXControls[i]); 
        }
 
-       int32 inputGroup        = 
-       Controls[index].id              = 0x8100;
-       Controls[index].flags   = B_MULTI_MIX_GROUP;
-       Controls[index].parent  = 0;
+       int32 inputGroup        
+               = Controls[index].id    = 0x8100;
+       Controls[index].flags           = B_MULTI_MIX_GROUP;
+       Controls[index].parent          = 0;
        strncpy(Controls[index].name, "Inputs", sizeof(Controls[index].name));
        index++;
 
-       for(size_t i = 0; i < _countof(InputControls); i++) {
+       for (size_t i = 0; i < _countof(InputControls); i++) {
                CreateMIXControlGroup(Info, index, inputGroup, 
InputControls[i]);
        }
 
-       int32 recordGroup       = 
-       Controls[index].id              = 0x8200;
-       Controls[index].flags   = B_MULTI_MIX_GROUP;
-       Controls[index].parent  = 0;
+       int32 recordGroup       
+               = Controls[index].id    = 0x8200;
+       Controls[index].flags           = B_MULTI_MIX_GROUP;
+       Controls[index].parent          = 0;
        strncpy(Controls[index].name, "Recording", 
sizeof(Controls[index].name));
        index++;
 
-       for(size_t i = 0; i < _countof(RecordControls); i++) {
+       for (size_t i = 0; i < _countof(RecordControls); i++) {
                CreateMIXControlGroup(Info, index, recordGroup, 
RecordControls[i]);
        }
 
@@ -515,32 +516,32 @@
 }
 
 
-status_t 
+status_t
 AC97::GetMix(multi_mix_value_info *Info)
 {
-       for(int32 i = 0; i < Info->item_count; i++) {
+       for (int32 i = 0; i < Info->item_count; i++) {
                
-               int32 Id  = Info->values[i].id;
+               int32 Id= Info->values[i].id;
                uint8 Reg = (Id >> 8) & 0xFF;
 
-               if((Reg & 0x01) || Reg > 0x7e) {
+               if ((Reg & 0x01) || Reg > 0x7e) {
                        TRACE_ALWAYS("Invalid AC97 register:%#04x.Bypass 
it.\n", Reg);
                        continue;
                }
 
                uint16 RegValue = fCDC->ReadCodec(Reg);
                
-               if((Id & MIX_Mute) == MIX_Mute) {
+               if ((Id & MIX_Mute) == MIX_Mute) {
                        Info->values[i].enable = (RegValue & 0x8000) != 0;
                        continue;
-               } 
+               }
                
-               if((Id & MIX_Boost) == MIX_Boost) {
+               if ((Id & MIX_Boost) == MIX_Boost) {
                        Info->values[i].enable = (RegValue & 0x0040) != 0;
                        continue;
                }
                
-               if((Id & MIX_MUX) == MIX_MUX) {
+               if ((Id & MIX_MUX) == MIX_MUX) {
                        Info->values[i].mux = (RegValue | (RegValue >> 8)) & 
0x7;
                        continue;
                }
@@ -549,9 +550,9 @@
                float base = mult * ((Id >> 16) & 0xff);
                TRACE_ALWAYS("mult:%f base:%f\n", mult, base);
 
-               if((Id & MIX_Gain) == MIX_Gain) {
-                       uint8 gain = (Id & MIX_Stereo) == MIX_Stereo ? 
-                                                 (RegValue >> 8) : RegValue;
+               if ((Id & MIX_Gain) == MIX_Gain) {
+                       uint8 gain = (Id & MIX_Stereo) == MIX_Stereo
+                               ? (RegValue >> 8) : RegValue;
                        gain &= ~0xc0;
 
                        Info->values[i].gain = mult * gain - base;
@@ -559,7 +560,7 @@
                        continue;
                }
 
-               if((Id & MIX_RGain) == MIX_RGain) {
+               if ((Id & MIX_RGain) == MIX_RGain) {
                        uint8 gain = RegValue & 0x3f;
                        Info->values[i].gain = mult * gain - base;
                        TRACE_ALWAYS("%#04x for RGain:%f <- %#04x\n", Reg, 
Info->values[i].gain, gain);
@@ -570,36 +571,36 @@
 }
 
 
-status_t 
+status_t
 AC97::SetMix(multi_mix_value_info *Info)
 {
-       for(int32 i = 0; i < Info->item_count; i++) {
+       for (int32 i = 0; i < Info->item_count; i++) {
                
-               int32 Id  = Info->values[i].id;
+               int32 Id = Info->values[i].id;
                uint8 Reg = (Id >> 8) & 0xFF;
 
-               if((Reg & 0x01) || Reg > 0x7e) {
+               if ((Reg & 0x01) || Reg > 0x7e) {
                        TRACE_ALWAYS("Invalid AC97 register:%#04x.Bypass 
it.\n", Reg);
                        continue;
                }
 
                uint16 RegValue = fCDC->ReadCodec(Reg);
 
-               if((Id & MIX_Mute) == MIX_Mute) {
-                       if(Info->values[i].enable) 
+               if ((Id & MIX_Mute) == MIX_Mute) {
+                       if (Info->values[i].enable)
                                RegValue |= 0x8000;
                        else
                                RegValue &= ~0x8000;
                }
                
-               if((Id & MIX_Boost) == MIX_Boost) {
-                       if(Info->values[i].enable) 
+               if ((Id & MIX_Boost) == MIX_Boost) {
+                       if (Info->values[i].enable)
                                RegValue |= 0x0040;
                        else
                                RegValue &= ~0x0040;
                }
                
-               if((Id & MIX_MUX) == MIX_MUX) {
+               if ((Id & MIX_MUX) == MIX_MUX) {
                        uint8 mux = Info->values[i].mux & 0x7;
                        RegValue = mux | (mux << 8);
                }
@@ -612,27 +613,27 @@
                gain += (gain > 0.) ? 0.5 : -0.5;
                uint8 gainValue = (uint8)gain;
 
-               if((Id & MIX_Gain) == MIX_Gain) {
-                       if((Id & MIX_Stereo) == MIX_Stereo) {
+               if ((Id & MIX_Gain) == MIX_Gain) {
+                       if ((Id & MIX_Stereo) == MIX_Stereo) {
                                RegValue &= ~0x3f00;
-                               RegValue |= (gainValue << 8); 
+                               RegValue |= (gainValue << 8);
                        } else {
                                RegValue &= ~0x3f;
-                               RegValue |= gainValue; 
+                               RegValue |= gainValue;
                        }
                        TRACE_ALWAYS("%#04x for Gain:%f -> %#04x\n", Reg, 
Info->values[i].gain, gainValue);
                }
 
-               if((Id & MIX_RGain) == MIX_RGain) {
+               if ((Id & MIX_RGain) == MIX_RGain) {
                        RegValue &= ~0x3f;
-                       RegValue |= gainValue; 
+                       RegValue |= gainValue;
                        TRACE_ALWAYS("%#04x for RGain:%f -> %#04x\n", Reg, 
Info->values[i].gain, gainValue);
                }
                
                TRACE_ALWAYS("%#04x Write:%#06x\n", Reg, RegValue);
 
                status_t status = fCDC->WriteCodec(Reg, RegValue);
-               if(status != B_OK) {
+               if (status != B_OK) {
                        TRACE_ALWAYS("Error set register %#04x to:%#06x\n", 
Reg, RegValue);
                }
        }

Modified: haiku/branches/developer/siarzhuk/sis7018/AC97.h
===================================================================
--- haiku/branches/developer/siarzhuk/sis7018/AC97.h    2010-06-01 18:55:37 UTC 
(rev 36992)
+++ haiku/branches/developer/siarzhuk/sis7018/AC97.h    2010-06-01 18:56:55 UTC 
(rev 36993)
@@ -1,12 +1,12 @@
 /*
- *     SiS 7018 Audio Driver.
- *     Copyright (c) 2002, 2008, 2009 S.Zharski <imker@xxxxxx>
+ *     SiS 7018, Trident 4D Wave DX/NX, Acer Lab M5451 Sound Driver.
+ *     Copyright (c) 2002, 2008 S.Zharski <imker@xxxxxx>
  *     Distributed under the terms of the MIT license.
  *
  */
 
 #ifndef _SiS7018_AC97_H_
-#define  _SiS7018_AC97_H_
+#define _SiS7018_AC97_H_
 
 #include "hmulti_audio.h"
 #include <OS.h>

Modified: haiku/branches/developer/siarzhuk/sis7018/Device.cpp
===================================================================
--- haiku/branches/developer/siarzhuk/sis7018/Device.cpp        2010-06-01 
18:55:37 UTC (rev 36992)
+++ haiku/branches/developer/siarzhuk/sis7018/Device.cpp        2010-06-01 
18:56:55 UTC (rev 36993)
@@ -16,7 +16,7 @@
 /*class SmartLock {
        mutex &fMutex;
 public:
-       SmartLock(mutex &m):fMutex(m) 
+       SmartLock(mutex &m):fMutex(m)
                                { mutex_lock(&fMutex); }
        ~SmartLock() { mutex_unlock(&fMutex); }
 };*/
@@ -34,13 +34,13 @@
                 /*fOpen(false),
                fDevice(device),
                fNonBlocking(false),            
-               fNotifyWriteSem(-1), 
+               fNotifyWriteSem(-1),
                */
-{ 
+{
 //     mutex_init(&fInitMutex, "Init_"DRIVER_NAME);
        //SmartLock lock(fInitMutex);
 
-       uint32 cmdRegister = gPCIModule->read_pci_config(PCIInfo.bus, 
+       uint32 cmdRegister = gPCIModule->read_pci_config(PCIInfo.bus,
                                                        PCIInfo.device, 
PCIInfo.function, PCI_command, 2);
        TRACE_ALWAYS("cmdRegister:%#010x\n", cmdRegister);
        cmdRegister |= PCI_command_io | PCI_command_memory | PCI_command_master;
@@ -53,7 +53,7 @@
        cpu_status cp = disable_interrupts();
        acquire_spinlock(&fHWSpinlock);
 
-       switch(fInfo.Id()) {
+       switch (fInfo.Id()) {
                case SiS7018:
                        WritePCI32(0x4c, 0x00000000);
                        WritePCI32(SiSCodecStatusReg, 0x000f0000);
@@ -84,7 +84,7 @@
 {
 //     mutex_destroy(&fInitMutex);
        
-       if(fBuffersReadySem > B_OK) {
+       if (fBuffersReadySem > B_OK) {
                delete_sem(fBuffersReadySem);
        }       
 }
@@ -101,20 +101,20 @@
        fOpen = true;
        return result; */
        
-       if(atomic_add(&fInterruptsNest, 1) == 0) {
-               install_io_interrupt_handler(fPCIInfo.u.h0.interrupt_line, 
+       if (atomic_add(&fInterruptsNest, 1) == 0) {
+               install_io_interrupt_handler(fPCIInfo.u.h0.interrupt_line,
                                                                                
                        InterruptHandler, this, 0);
-               TRACE("Interrupt handler installed at line %d.\n", 
+               TRACE("Interrupt handler installed at line %d.\n",
                                                                                
                        fPCIInfo.u.h0.interrupt_line);
        }
 
        status_t status = fPlaybackStream.Start();
-       if(status != B_OK) {
+       if (status != B_OK) {
                TRACE_ALWAYS("Error of starting playback stream:%#010x\n", 
status);
        }
 
        status = fRecordStream.Start();
-       if(status != B_OK) {
+       if (status != B_OK) {
                TRACE_ALWAYS("Error of starting record stream:%#010x\n", 
status);
        }
 
@@ -128,19 +128,19 @@
        TRACE("closed!\n");
        
        status_t status = fPlaybackStream.Stop();
-       if(status != B_OK) {
+       if (status != B_OK) {
                TRACE_ALWAYS("Error of stopping playback stream:%#010x\n", 
status);
        }
 
        status = fRecordStream.Stop();
-       if(status != B_OK) {
+       if (status != B_OK) {
                TRACE_ALWAYS("Error of stopping record stream:%#010x\n", 
status);
        }
        
-       if(atomic_add(&fInterruptsNest, -1) == 1) {
-               remove_io_interrupt_handler(fPCIInfo.u.h0.interrupt_line, 
+       if (atomic_add(&fInterruptsNest, -1) == 1) {
+               remove_io_interrupt_handler(fPCIInfo.u.h0.interrupt_line,
                                                                                
                        InterruptHandler, this);
-               TRACE("Interrupt handler at line %d uninstalled.\n", 
+               TRACE("Interrupt handler at line %d uninstalled.\n",
                                                                                
                        fPCIInfo.u.h0.interrupt_line);
        }
 
@@ -185,7 +185,7 @@
 Device::Control(uint32 op, void *buffer, size_t length)
 {
        switch (op) {
-               case B_MULTI_GET_DESCRIPTION: 
+               case B_MULTI_GET_DESCRIPTION:
                        return _MultiGetDescription((multi_description*)buffer);
 
                case B_MULTI_GET_EVENT_INFO:
@@ -256,7 +256,7 @@
 status_t
 Device::SetupDevice()
 {
-       return B_OK; 
+       return B_OK;
 }
 
 
@@ -270,9 +270,9 @@
 uint16
 Device::ReadCodec(uint8 cdcReg)
 {
-       uint8  rdReg = SiSCodecReadReg;
+       uint8 rdReg = SiSCodecReadReg;
        uint32 statusRW = 0x00008000;
-       switch(fInfo.Id()) {
+       switch (fInfo.Id()) {
                case SiS7018:
                        break;
                case TridentDX:
@@ -301,15 +301,15 @@
        
        uint32 status = statusRW;
        uint16 TO = TrCodecTimeout;
-       for(; TO > 0 && (status & statusRW); TO--) {
+       for (; TO > 0 && (status & statusRW); TO--) {
                status = ReadPCI32(rdReg);
        }
 
        release_spinlock(&fHWSpinlock);
        restore_interrupts(cp);
        
-       if(TO == 0) {
-         TRACE_ALWAYS("Timed out reg:%#04x.\n", cdcReg);
+       if (TO == 0) {
+               TRACE_ALWAYS("Timed out reg:%#04x.\n", cdcReg);
        }
 
        return (status >> 16) & 0xffff;
@@ -319,9 +319,9 @@
 status_t
 Device::WriteCodec(uint8 cdcReg, uint16 value)
 {
-       uint8  wrReg = SiSCodecWriteReg;
+       uint8 wrReg = SiSCodecWriteReg;
        uint32 statusRW = 0x00008000;
-       switch(fInfo.Id()) {
+       switch (fInfo.Id()) {
                case SiS7018:
                        break;
                case TridentDX:
@@ -348,7 +348,7 @@
        uint32 status = statusRW;
                
        uint16 TO = TrCodecTimeout;
-       for(; TO > 0 && (status & statusRW); TO--) {
+       for (; TO > 0 && (status & statusRW); TO--) {
                status = ReadPCI32(wrReg);
        }
        
@@ -357,15 +357,15 @@
        release_spinlock(&fHWSpinlock);
        restore_interrupts(cp);
        
-       if(TO == 0) {
-         TRACE_ALWAYS("Timed out reg:%#04x.\n", cdcReg);
+       if (TO == 0) {
+               TRACE_ALWAYS("Timed out reg:%#04x.\n", cdcReg);
        }
 
        return (TO > 0) ? B_OK : B_TIMED_OUT;
 }
 
        
-uint8 
+uint8
 Device::ReadPCI8(int offset)
 {
        return gPCIModule->read_io_8(fIOBase + offset);
@@ -387,7 +387,7 @@
 
 
 void
-Device::WritePCI8(int offset, uint8  value)
+Device::WritePCI8(int offset, uint8 value)
 {
        gPCIModule->write_io_8(fIOBase + offset, value);
 }
@@ -408,7 +408,7 @@
 
 
 cpu_status
-Device::Lock() 
+Device::Lock()
 {
        cpu_status st = disable_interrupts();
        acquire_spinlock(&fHWSpinlock);
@@ -417,7 +417,7 @@
 
 
 void
-Device::Unlock(cpu_status st) 
+Device::Unlock(cpu_status st)
 {
        release_spinlock(&fHWSpinlock);
        restore_interrupts(st);
@@ -428,38 +428,37 @@
 Device::_MultiGetDescription(multi_description *multiDescription)
 {
        multi_channel_info channel_descriptions[] = {
-               { 0, B_MULTI_OUTPUT_CHANNEL, B_CHANNEL_LEFT | 
B_CHANNEL_STEREO_BUS,  0 },
+               { 0, B_MULTI_OUTPUT_CHANNEL, B_CHANNEL_LEFT | 
B_CHANNEL_STEREO_BUS,      0 },
                { 1, B_MULTI_OUTPUT_CHANNEL, B_CHANNEL_RIGHT | 
B_CHANNEL_STEREO_BUS, 0 },
-               { 2, B_MULTI_INPUT_CHANNEL,  B_CHANNEL_LEFT | 
B_CHANNEL_STEREO_BUS,  0 },
-               { 3, B_MULTI_INPUT_CHANNEL,  B_CHANNEL_RIGHT | 
B_CHANNEL_STEREO_BUS, 0 },
-               { 4, B_MULTI_OUTPUT_BUS,         B_CHANNEL_LEFT | 
B_CHANNEL_STEREO_BUS,  B_CHANNEL_MINI_JACK_STEREO },
-               { 5, B_MULTI_OUTPUT_BUS,         B_CHANNEL_RIGHT | 
B_CHANNEL_STEREO_BUS, B_CHANNEL_MINI_JACK_STEREO },
-               { 6, B_MULTI_INPUT_BUS,          B_CHANNEL_LEFT | 
B_CHANNEL_STEREO_BUS,  B_CHANNEL_MINI_JACK_STEREO },
+               { 2, B_MULTI_INPUT_CHANNEL,      B_CHANNEL_LEFT | 
B_CHANNEL_STEREO_BUS,  0 },
+               { 3, B_MULTI_INPUT_CHANNEL,      B_CHANNEL_RIGHT | 
B_CHANNEL_STEREO_BUS, 0 },
+               { 4, B_MULTI_OUTPUT_BUS,         B_CHANNEL_LEFT | 
B_CHANNEL_STEREO_BUS,  B_CHANNEL_MINI_JACK_STEREO },
+               { 5, B_MULTI_OUTPUT_BUS,         B_CHANNEL_RIGHT | 
B_CHANNEL_STEREO_BUS, B_CHANNEL_MINI_JACK_STEREO },
+               { 6, B_MULTI_INPUT_BUS,          B_CHANNEL_LEFT | 
B_CHANNEL_STEREO_BUS,  B_CHANNEL_MINI_JACK_STEREO },
                { 7, B_MULTI_INPUT_BUS,          B_CHANNEL_RIGHT | 
B_CHANNEL_STEREO_BUS, B_CHANNEL_MINI_JACK_STEREO },
        };
 
        multi_description Description;
-       if(user_memcpy(&Description, multiDescription, 
sizeof(multi_description)) != B_OK) {
+       if (user_memcpy(&Description, multiDescription, 
sizeof(multi_description)) != B_OK)
                return B_BAD_ADDRESS;
-       }
-
+       
        Description.interface_version = B_CURRENT_INTERFACE_VERSION;
        Description.interface_minimum = B_CURRENT_INTERFACE_VERSION;
 
-       strncpy(Description.friendly_name, fInfo.Name(), 
+       strncpy(Description.friendly_name, fInfo.Name(),
                                                                        
sizeof(Description.friendly_name));
        
-       strncpy(Description.vendor_info, "S.Zharski", 
+       strncpy(Description.vendor_info, "S.Zharski",
                                                                        
sizeof(Description.vendor_info));
        
-       Description.output_channel_count          = 2;
-       Description.input_channel_count           = 2;
-       Description.output_bus_channel_count = 2;
-       Description.input_bus_channel_count  = 2;
-       Description.aux_bus_channel_count         = 0;
+       Description.output_channel_count                = 2;
+       Description.input_channel_count                 = 2;
+       Description.output_bus_channel_count    = 2;
+       Description.input_bus_channel_count             = 2;
+       Description.aux_bus_channel_count               = 0;
 
        Description.output_rates        = B_SR_48000;
-       Description.input_rates = B_SR_48000;
+       Description.input_rates         = B_SR_48000;
 
        Description.min_cvsr_rate = 0;
        Description.max_cvsr_rate = 0;
@@ -468,20 +467,19 @@
        Description.input_formats = B_FMT_16BIT;
        Description.lock_sources = B_MULTI_LOCK_INTERNAL;
        Description.timecode_sources = 0;
-       Description.interface_flags = 
-                               B_MULTI_INTERFACE_PLAYBACK | 
B_MULTI_INTERFACE_RECORD;
+       Description.interface_flags
+               = B_MULTI_INTERFACE_PLAYBACK | B_MULTI_INTERFACE_RECORD;
        Description.start_latency = 3000;
 
        Description.control_panel[0] = '\0';
 
-       if(user_memcpy(multiDescription, &Description, 
sizeof(multi_description)) != B_OK) {
+       if (user_memcpy(multiDescription, &Description, 
sizeof(multi_description)) != B_OK)
                return B_BAD_ADDRESS;
-       }
 
-       if (Description.request_channel_count >= 
-                       (int)(sizeof(channel_descriptions) / 
sizeof(channel_descriptions[0]))) 
+       if (Description.request_channel_count
+                       >= (int)(sizeof(channel_descriptions) / 
sizeof(channel_descriptions[0]))) 
        {
-               if(user_memcpy(multiDescription->channels, 
+               if (user_memcpy(multiDescription->channels,
                                        &channel_descriptions, 
sizeof(channel_descriptions)) != B_OK)
                        return B_BAD_ADDRESS;
        }
@@ -518,15 +516,10 @@
        Format->input_latency = 0;
        Format->timecode_kind = 0;
 
-       Format->output.rate = 
-       Format->input.rate = B_SR_48000;
+       Format->output.rate     = Format->input.rate = B_SR_48000;
+       Format->output.cvsr     = Format->input.cvsr = 48000;
+       Format->output.format = Format->input.format = B_FMT_16BIT;
 
-       Format->output.cvsr = 
-       Format->input.cvsr = 48000;
-       
-       Format->output.format = 
-       Format->input.format = B_FMT_16BIT;
-
        return B_OK;
 }
 
@@ -538,14 +531,14 @@
 }
 
 
-status_t 
+status_t
 Device::_MultiGetMix(multi_mix_value_info *Info)
 {
        return fAC97.GetMix(Info);
 }
 
 
-status_t 
+status_t
 Device::_MultiSetMix(multi_mix_value_info *Info)
 {
        return fAC97.SetMix(Info);
@@ -573,37 +566,37 @@
 }
 
 
-status_t 
+status_t
 Device::_MultiBufferExchange(multi_buffer_info* bufferInfo)
 {
-       status_t status = acquire_sem_etc(fBuffersReadySem, 1, 
+       status_t status = acquire_sem_etc(fBuffersReadySem, 1,
                                                                
B_RELATIVE_TIMEOUT | B_CAN_INTERRUPT, 50000);
-       if(status == B_TIMED_OUT) {
+       if (status == B_TIMED_OUT) {
                TRACE_ALWAYS("Timeout during buffers exchange.\n");
        }
 
        multi_buffer_info BufferInfo;
-       if(user_memcpy(&BufferInfo, bufferInfo, sizeof(multi_buffer_info)) != 
B_OK) {
+       if (user_memcpy(&BufferInfo, bufferInfo, sizeof(multi_buffer_info)) != 
B_OK) {
                return B_BAD_ADDRESS;
        }
 
        cpu_status cst = Lock();
 
-       fPlaybackStream.ExchangeBuffers(BufferInfo.played_real_time, 
+       fPlaybackStream.ExchangeBuffers(BufferInfo.played_real_time,
                                        BufferInfo.played_frames_count, 
BufferInfo.playback_buffer_cycle);
 
-       fRecordStream.ExchangeBuffers(BufferInfo.recorded_real_time, 
+       fRecordStream.ExchangeBuffers(BufferInfo.recorded_real_time,
                                        BufferInfo.recorded_frames_count, 
BufferInfo.record_buffer_cycle);
        
        Unlock(cst);
 
-//     TRACE("rt:%lld; fc:%lld; bc:%d; csp:%#010x\n", Info->played_real_time, 
+//     TRACE("rt:%lld; fc:%lld; bc:%d; csp:%#010x\n", Info->played_real_time,
 //                                     Info->played_frames_count, 
Info->playback_buffer_cycle, fPlaybackStream.fCSP);
 
-       TRACE("rt:%lld; fc:%lld; bc:%d\n", BufferInfo.recorded_real_time, 
+       TRACE("rt:%lld; fc:%lld; bc:%d\n", BufferInfo.recorded_real_time,
                                        BufferInfo.recorded_frames_count, 
BufferInfo.record_buffer_cycle);
 
-       if(user_memcpy(bufferInfo, &BufferInfo, sizeof(multi_buffer_info)) != 
B_OK) {
+       if (user_memcpy(bufferInfo, &BufferInfo, sizeof(multi_buffer_info)) != 
B_OK) {
                return B_BAD_ADDRESS;
        }
 
@@ -615,7 +608,7 @@
 Device::InterruptHandler(void *InterruptParam)
 {
        Device *device = (Device*)InterruptParam;
-       if(device == 0) {
+       if (device == 0) {
                TRACE_ALWAYS("Invalid parameter in the interrupt handler.\n");
                return B_HANDLED_INTERRUPT;
        }
@@ -625,12 +618,12 @@
        acquire_spinlock(&device->fHWSpinlock);
 
        uint32 mask = device->ReadPCI32(TrMiscINTReg);
-       if(mask & 0x00000020) {
+       if (mask & 0x00000020) {
                uint32 SignaledChannelsMask = 
device->ReadPCI32(TrAddressINTBReg);
                
                result = 
device->fPlaybackStream.InterruptHandler(SignaledChannelsMask);
 
-               if(result == B_UNHANDLED_INTERRUPT)
+               if (result == B_UNHANDLED_INTERRUPT)
                        result = 
device->fRecordStream.InterruptHandler(SignaledChannelsMask);
                
                device->WritePCI32(TrAddressINTBReg, SignaledChannelsMask);

Modified: haiku/branches/developer/siarzhuk/sis7018/Device.h
===================================================================
--- haiku/branches/developer/siarzhuk/sis7018/Device.h  2010-06-01 18:55:37 UTC 
(rev 36992)
+++ haiku/branches/developer/siarzhuk/sis7018/Device.h  2010-06-01 18:56:55 UTC 
(rev 36993)
@@ -1,6 +1,6 @@
 /*
- *     SiS 7018 Audio Driver.
- *     Copyright (c) 2002, 2008, 2009 S.Zharski <imker@xxxxxx>
+ *     SiS 7018, Trident 4D Wave DX/NX, Acer Lab M5451 Sound Driver.
+ *     Copyright (c) 2002, 2008 S.Zharski <imker@xxxxxx>
  *     Distributed under the terms of the MIT license.
  *
  */
@@ -17,10 +17,10 @@
 //#include <lock.h>
 
 // card ids for supported audio hardware
-const uint32 SiS7018   = 0x70181039; 
-const uint32 ALi5451   = 0x545110b9;
-const uint32 TridentDX = 0x20001023; 
-const uint32 TridentNX = 0x20011023; 
+const uint32 SiS7018   = 0x70181039;
+const uint32 ALi5451   = 0x545110b9;
+const uint32 TridentDX = 0x20001023;
+const uint32 TridentNX = 0x20011023;
 
 
 class Device : public Codec {
@@ -31,10 +31,10 @@
                        const char*                     fName;
        //                                                      Info(const 
uint32 Id, const char* Name)
        //                                                                      
: fId(Id), fName(Name) { }
-                       inline const char*      Name()     { return  fName; }
-                       inline uint16           DeviceId() { return (fId >> 16) 
& 0xffff; }
-                       inline uint16           VendorId() { return (fId)       
        & 0xffff; }
-                       inline uint32           Id()       { return  fId; }
+                       inline const char*      Name()          { return fName; 
}
+                       inline uint16           DeviceId()      { return (fId 
>> 16) & 0xffff; }
+                       inline uint16           VendorId()      { return (fId) 
& 0xffff; }
+                       inline uint32           Id()            { return fId; }
                };
 
                                                        Device(Info 
&DeviceInfo, pci_info &PCIInfo);
@@ -58,7 +58,7 @@
                uint8                           ReadPCI8(int offset);
                uint16                          ReadPCI16(int offset);
                uint32                          ReadPCI32(int offset);
-               void                            WritePCI8(int offset, uint8  
value);
+               void                            WritePCI8(int offset, uint8 
value);
                void                            WritePCI16(int offset, uint16 
value);
                void                            WritePCI32(int offset, uint32 
value);
        
@@ -112,3 +112,4 @@
 };
 
 #endif //_SiS7018_DEVICE_H_
+

Modified: haiku/branches/developer/siarzhuk/sis7018/Driver.cpp
===================================================================
--- haiku/branches/developer/siarzhuk/sis7018/Driver.cpp        2010-06-01 
18:55:37 UTC (rev 36992)
+++ haiku/branches/developer/siarzhuk/sis7018/Driver.cpp        2010-06-01 
18:56:55 UTC (rev 36993)
@@ -1,6 +1,6 @@
 /*
- *     SiS 7018 Audio Driver.
- *     Copyright (c) 2002, 2008, 2009 S.Zharski <imker@xxxxxx>
+ *     SiS 7018, Trident 4D Wave DX/NX, Acer Lab M5451 Sound Driver.
+ *     Copyright (c) 2002, 2008 S.Zharski <imker@xxxxxx>
  *     Distributed under the terms of the MIT license.
  *
  */
@@ -15,7 +15,7 @@
 #include "Device.h"
 #include "Settings.h"
 
-#define DEVNAME 32 
+#define DEVNAME 32
 
 int32 api_version = B_CUR_DRIVER_API_VERSION;
 
@@ -31,8 +31,8 @@
 pci_module_info *gPCIModule = NULL;
 
 static Device::Info cardInfos[] = {
-       {SiS7018,       "SiS 7018"  },
-       {ALi5451,       "ALi 5451"  },
+       {SiS7018,       "SiS 7018"      },
+       {ALi5451,       "ALi 5451"      },
        {TridentDX,     "Trident DX"},
        {TridentNX,     "Trident NX"}
 };
@@ -50,9 +50,9 @@
        for (long i = 0; B_OK == (*gPCIModule->get_nth_pci_info)(i, &info); 
i++) {
                for (size_t idx = 0; idx < _countof(cardInfos); idx++) {
                        if (info.vendor_id == cardInfos[idx].VendorId() &&
-                               info.device_id == cardInfos[idx].DeviceId()) 
+                               info.device_id == cardInfos[idx].DeviceId())
                        {
-                               TRACE_ALWAYS("Found:%s %#010x\n", 
+                               TRACE_ALWAYS("Found:%s %#010x\n",
                                                                        
cardInfos[idx].Name(), cardInfos[idx].Id());
                                put_module(B_PCI_MODULE_NAME);
                                return B_OK;
@@ -81,9 +81,9 @@
        for (long i = 0; B_OK == (*gPCIModule->get_nth_pci_info)(i, &info); 
i++) {
                for (size_t idx = 0; idx < _countof(cardInfos); idx++) {
                        if (info.vendor_id == cardInfos[idx].VendorId() &&
-                               info.device_id == cardInfos[idx].DeviceId()) 
+                               info.device_id == cardInfos[idx].DeviceId())
                        {
-                               if(numCards == MAX_DEVICES) {
+                               if (numCards == MAX_DEVICES) {
                                        break;
                                }
 
@@ -112,7 +112,7 @@
                }
        }
 
-       if(numCards == 0) {
+       if (numCards == 0) {
                put_module(B_PCI_MODULE_NAME);
                return ENODEV;
        }

[... truncated: 414 lines follow ...]

Other related posts:

  • » [haiku-commits] r36993 - haiku/branches/developer/siarzhuk/sis7018 - zharik