Exemple #1
0
static void
dprint_font_t(const pl_font_t *pfont)
{	
    dprint_font_name(pfont);
    dprintf3("storage=%d scaling=%d type=%d ",
             pfont->storage, pfont->scaling_technology, pfont->font_type);
    dprint_cc(pfont->character_complement);
    dputs(";\n   ");
    dprint_font_params_t(&pfont->params);
}
Exemple #2
0
static void
dprint_font_map(const pl_symbol_map_t *pmap)
{
    if (pmap != 0)
        dprintf3("selected symbol set id:%d type:%d format:%s\n", pl_get_uint16(pmap->id),
                 pmap->type, (pmap->format == 1 ? "MSL" : "Unicode"));
    else
        dprintf("selected symbol set NULL\n");

}
Exemple #3
0
/*****************************************************************************
    SoundInitDmaChannel()

*****************************************************************************/
NTSTATUS    SoundInitDmaChannel( IN OUT PGLOBAL_DEVICE_INFO pGDI,
                              IN OUT PULONG DmaChannel,
                              IN     ULONG  DmaBufferSize )
{
        /***** Local Variables *****/

    DEVICE_DESCRIPTION  DeviceDescription;              // DMA adapter object

                /***** Start *****/

    dprintf3(("SoundInitDmaChannel(): Start"));
    dprintf4((" SoundInitDmaChannel():  DMA Channel     = %u", *DmaChannel));
    dprintf4((" SoundInitDmaChannel():  DMA Buffer Size = %XH", DmaBufferSize));

    //
    // See if we can get this channel
    //

    //
    // Zero the device description structure.
    //

    RtlZeroMemory(&DeviceDescription,
                  sizeof(DEVICE_DESCRIPTION));

    //
    // Get the adapter object for this card.
    //

    DeviceDescription.Version        = DEVICE_DESCRIPTION_VERSION;
    DeviceDescription.AutoInitialize = TRUE;
    DeviceDescription.ScatterGather  = FALSE;
    DeviceDescription.DmaChannel     = *DmaChannel;
    DeviceDescription.InterfaceType  = Isa;                 // Must use Isa DMA
    DeviceDescription.DmaSpeed       = Compatible;
    DeviceDescription.MaximumLength  = DmaBufferSize;
    DeviceDescription.BusNumber      = pGDI->BusNumber;

    //
    // Check the DMA Channel to set the DMA width
    //
    if ( *DmaChannel > 4 )
        {
        // 16 Bit DMA
        DeviceDescription.DmaWidth       = Width16Bits;
        }
    else
        {
        // 8 Bit DMA
        DeviceDescription.DmaWidth       = Width8Bits;
        }

    return SoundGetCommonBuffer(&DeviceDescription, &pGDI->WaveInfo.DMABuf);

}           // End SoundInitDmaChannel()
void DogStateCart3::write_frame(int nframe, const char* framedir) const
{
    //DogState::write(nframe,framedir);
    const double t = get_time();
    WriteStateArray(framedir, "q", *q, t, nframe);
    if(aux->numel() > 0)
    {
        dprintf3("printing aux array");
        WriteStateArray(framedir, "a", *aux, t, nframe);
    }
}
Exemple #5
0
/* modules were compiled with DEBUG set. */
#undef gs_log_error             /* in case DEBUG isn't set */
int
gs_log_error(int err, const char *file, int line)
{
    if (gs_log_errors) {
        if (file == NULL)
            dprintf1("Returning error %d.\n", err);
        else
            dprintf3("%s(%d): Returning error %d.\n",
                     (const char *)file, line, err);
    }
    return err;
}
Exemple #6
0
 DWORD AutoThreadEntry(PVOID Context)
 {
     int NumberOfBuffers;
     Half = 0;
     InterruptHalf = 0;

     dprintf3(("Auto thread starting"));

     for (; ; ) {
         WaitForSingleObject(AutoEvent, INFINITE);

         dprintf3(("Got event"));

         EnterCriticalSection(&WaveDeviceCritSec);

         dprintf2(("Playing %d buffers", BuffersToPlay));

         NumberOfBuffers = BuffersToPlay;
         BuffersToPlay = 0;

         LeaveCriticalSection(&WaveDeviceCritSec);

         while (NumberOfBuffers-- > 0) {

             UINT rc;

             rc =
             (Input ? waveInAddBuffer : waveOutWrite)
                 (hWave, &WaveHdr[Half], sizeof(WAVEHDR));

             if (rc != 0) {
                 dprintf1(("Got bad return on Add Buffer %x", rc));
             }

             Half = 1 - Half;
         }
     }

     return 0;
 }
Exemple #7
0
// called by the irq function in the hardware object when we get an interrupt
// first call _vUpdateProcessed() to update the dma amd audio buffer related
// stuff. Next if we have buffers on the primary queue try to read/write them
// to the audiobuffer. Look at the buffers on the done queue and see if they
// can be returned and finally process any events pending.
void WAVESTREAM::Process(void)
{
 PSTREAMBUFFER ptemp;
 ULONG         ulCurBytesProcessed = 0;
 ULONG         bytesinc;

   switch (ulStreamType & STREAM_WRITE) {
   case STREAM_WRITE:
   {
   	OSS16_StreamGetPos(this, &ulCurBytesProcessed);
   	if(ulCurBytesProcessed == 0) {
		//shouldn't happen
		DebugInt3();
		return;
	}
   	bytesinc           = ulCurBytesProcessed - _ulBytesProcessed;
	dprintf4(("Process: %lx %x", ulCurBytesProcessed, (USHORT)bytesinc));
	if(ulCurBytesProcessed < _ulBytesProcessed) {
       		dprintf(("WARNING: Process: Current pos %ld incr %d", ulCurBytesProcessed, (USHORT)bytesinc));
	}
   	_ulBytesProcessed  = ulCurBytesProcessed;

      	while(bytesinc) {
      	  if(qhDone.IsElements()) {  // if there are buffers that have been
                                  // completly written to the audio buffer
                                  // check the first one on the done queue
                                  // if it's data has been consumed by
                                  // the hardware return it
         	ptemp = (PSTREAMBUFFER)qhDone.Head();
		ptemp->ulDonepos += bytesinc;
		bytesinc          = 0;
		if(ptemp->ulDonepos >= ptemp->ulBuffsz) {
			//calc position in next buffer
			bytesinc = ptemp->ulDonepos - ptemp->ulBuffsz;
			dprintf3(("Process: Return buffer %lx size %d", ptemp->pBuffptr, ptemp->ulBuffsz));
		 	ReturnBuffer();
		}
      	  }
	  else	break; //shouldn't happen
      	}
	AddBuffers(FALSE);
	break;
   }
   case STREAM_READ:
	while(_vReadAudioBuf());
	break;
   default:
      break;
   } /* endswitch */

   ProcessEvents();
}
Exemple #8
0
VOID SBPROResetADCHardware(PGLOBAL_DEVICE_INFO pGDI)
{
   dprintf3(( "SBPROResetADCHardware" ));

   //
   //  Just set the volume - the code in SBPROSetVolume will now
   //  set the volumes correctly because input is no longer active
   //

   SBPROSetVolume(pGDI, ControlLineoutAuxVolume);
   SBPROSetVolume(pGDI, ControlLineoutMidioutVolume);
   SBPROSetVolume(pGDI, ControlLineoutInternalCDVolume);

} // SBPROResetADCHardware()
Exemple #9
0
 void CloseWaveDevice(void)
 {

     dprintf3(("Closeing wave device"));

     QuiesceAuto();

     if (hWave != NULL) {
         (Input ? waveInReset : waveOutReset)(hWave);

         WaveActive = FALSE;

         (Input ? waveInClose : waveOutClose)(hWave);

         hWave = NULL;
     }
 }
Exemple #10
0
/* Dump an array. */
void
debug_dump_array(const ref *array)
{	const ref_packed *pp;
	unsigned int type = r_type(array);
	uint len;

	switch (type)
	   {
	default:
		dprintf2 ("%s at 0x%lx isn't an array.\n",
			  (type < countof(type_strings) ?
			   type_strings[type] : "????"),
			  (ulong)array);
		return;
	case t_oparray:
		/* This isn't really an array, but we'd like to see */
		/* its contents anyway. */
		debug_dump_array(op_array_table.value.refs + op_index(array) -
				 op_def_count);
		return;
	case t_array:
	case t_mixedarray:
	case t_shortarray: 
		;
	   }

	/* This "packed" loop works for all array-types. */
	for ( len = r_size (array), pp = array->value.packed;
	      len > 0;
	      len--, pp = packed_next(pp))
	   {	ref temp;
		packed_get(pp, &temp);
		dprintf3("..%04x%c 0x%02x ", 
			 (uint)pp & 0xffff,
			 ((r_is_packed(pp)) ? '*' : ':'),
			 r_type(&temp));
		debug_dump_one_ref(&temp);
		dputc ('\n');
	   }
}
Exemple #11
0
 void WaveCallback(HWAVEOUT hWave, UINT msg, DWORD dwUser, DWORD dw1,
                   DWORD dw2)
 {
     switch (msg) {

     case MM_WOM_DONE:
     case MM_WIM_DATA:

         dprintf3(("Buffer complete"));

         //
         // If we use the critical section here we deadlock ourselves because
         // the call sits behind us on the thread!
         //

         EnterCriticalSection(&WaveDeviceCritSec);

         SetDMAPosition((!Auto || !InterruptHalf) ? BlockSize : BlockSize * 2);
         if (Auto) {

             UINT rc;

             BuffersToPlay++;

             SetEvent(AutoEvent);
             InterruptHalf = 1 - InterruptHalf;
         } else {
             WaveActive = FALSE;
             SetTerminalCount(FALSE);
         }
         GenerateInterrupt();
         LeaveCriticalSection(&WaveDeviceCritSec);


         break;
     }
 }
Exemple #12
0
 // evaluate at a point in the interval
 bool eval(double x, Polynomial* p)
 {
   _pv.eval(x,p);
   _num_evals++;
   dprintf3("iter %d: value at x=%24.16e is %24.16e",_num_evals,x,_pv.v());
   if(_num_evals > 30)
   {
     var_epsilon *= 2;
     assert_lt(_num_evals,100); // pure bisection does better than this
   }
   if(_pv.a() < var_epsilon) _done=true;
   //
   // confirm that the point is in the interval
   //assert_gt(x,low().x()); assert_lt(x,hgh().x());
   if(x<=low().x())
   {
     dprintf("x=%24.16e falls below lower bound %24.16e",x,low().x());
     return _done;
   }
   if(x>=hgh().x())
   {
     dprintf("x=%24.16e lands above upper bound %24.16e",x,hgh().x());
     return _done;
   }
   if(_pv.v() > 0.)
   {
     low(_pv);
     _using_hgh = false;
   }
   else
   {
     hgh(_pv);
     _using_hgh = true;
   }
   return _done;
 }
Exemple #13
0
JNIEXPORT jintArray JNICALL Java_sun_security_smartcardio_PCSC_SCardGetStatusChange
    (JNIEnv *env, jclass thisClass, jlong jContext, jlong jTimeout,
    jintArray jCurrentState, jobjectArray jReaderNames)
{
    SCARDCONTEXT context = (SCARDCONTEXT)jContext;
    LONG rv;
    int readers = (*env)->GetArrayLength(env, jReaderNames);
    SCARD_READERSTATE *readerState;
    int i;
    jintArray jEventState = NULL;
    int *currentState = NULL;
    const char *readerName;

    readerState = calloc(readers, sizeof(SCARD_READERSTATE));
    if (readerState == NULL && readers > 0) {
        throwOutOfMemoryError(env, NULL);
        return NULL;
    }

    currentState = (*env)->GetIntArrayElements(env, jCurrentState, NULL);
    if (currentState == NULL) {
        free(readerState);
        return NULL;
    }

    for (i = 0; i < readers; i++) {
        readerState[i].szReader = NULL;
    }

    for (i = 0; i < readers; i++) {
        jobject jReaderName = (*env)->GetObjectArrayElement(env, jReaderNames, i);
        if ((*env)->ExceptionCheck(env)) {
            goto cleanup;
        }
        readerName = (*env)->GetStringUTFChars(env, jReaderName, NULL);
        if (readerName == NULL) {
            goto cleanup;
        }
        readerState[i].szReader = strdup(readerName);
        (*env)->ReleaseStringUTFChars(env, jReaderName, readerName);
        if (readerState[i].szReader == NULL) {
            throwOutOfMemoryError(env, NULL);
            goto cleanup;
        }
        readerState[i].pvUserData = NULL;
        readerState[i].dwCurrentState = currentState[i];
        readerState[i].dwEventState = SCARD_STATE_UNAWARE;
        readerState[i].cbAtr = 0;
        (*env)->DeleteLocalRef(env, jReaderName);
    }

    if (readers > 0) {
        rv = CALL_SCardGetStatusChange(context, (DWORD)jTimeout, readerState, readers);
        if (handleRV(env, rv)) {
            goto cleanup;
        }
    }

    jEventState = (*env)->NewIntArray(env, readers);
    if (jEventState == NULL) {
        goto cleanup;
    }
    for (i = 0; i < readers; i++) {
        jint eventStateTmp;
        dprintf3("-reader status %s: 0x%X, 0x%X\n", readerState[i].szReader,
            readerState[i].dwCurrentState, readerState[i].dwEventState);
        eventStateTmp = (jint)readerState[i].dwEventState;
        (*env)->SetIntArrayRegion(env, jEventState, i, 1, &eventStateTmp);
        if ((*env)->ExceptionCheck(env)) {
            jEventState = NULL;
            goto cleanup;
        }
    }
cleanup:
    (*env)->ReleaseIntArrayElements(env, jCurrentState, currentState, JNI_ABORT);
    for (i = 0; i < readers; i++) {
        free((char *)readerState[i].szReader);
    }
    free(readerState);
    return jEventState;
}
Exemple #14
0
int search_bd_buf(char *buf, int len_bytes, unsigned long bd_offset_bytes,
		int *nr_populated_bdes)
{
	unsigned long i;
	int total_entries = 0;

	dprintf3("%s(%p, %x, %lx, ...) buf end: %p\n", __func__, buf,
			len_bytes, bd_offset_bytes, buf + len_bytes);

	for (i = 0; i < len_bytes; i += sizeof(unsigned long)) {
		unsigned long bd_index = (bd_offset_bytes + i) / sizeof(unsigned long);
		unsigned long *bounds_dir_entry_ptr = (unsigned long *)&buf[i];
		unsigned long bounds_dir_entry;
		unsigned long bd_for_vaddr;
		unsigned long bt_start;
		unsigned long bt_tail;
		int nr_entries;

		dprintf4("%s() loop i: %ld bounds_dir_entry_ptr: %p\n", __func__, i,
				bounds_dir_entry_ptr);

		bounds_dir_entry = *bounds_dir_entry_ptr;
		if (!bounds_dir_entry) {
			dprintf4("no bounds dir at index 0x%lx / 0x%lx "
				 "start at offset:%lx %lx\n", bd_index, bd_index,
					bd_offset_bytes, i);
			continue;
		}
		dprintf3("found bounds_dir_entry: 0x%lx @ "
			 "index 0x%lx buf ptr: %p\n", bounds_dir_entry, i,
					&buf[i]);
		/* mask off the enable bit: */
		bounds_dir_entry &= ~0x1;
		(*nr_populated_bdes)++;
		dprintf4("nr_populated_bdes: %p\n", nr_populated_bdes);
		dprintf4("*nr_populated_bdes: %d\n", *nr_populated_bdes);

		bt_start = bounds_dir_entry;
		bt_tail = bounds_dir_entry + MPX_BOUNDS_TABLE_SIZE_BYTES - 1;
		if (!vaddr_mapped_by_range(bt_start)) {
			printf("bounds directory 0x%lx points to nowhere\n",
					bounds_dir_entry);
			mpx_dig_abort();
		}
		if (!vaddr_mapped_by_range(bt_tail)) {
			printf("bounds directory end 0x%lx points to nowhere\n",
					bt_tail);
			mpx_dig_abort();
		}
		/*
		 * Each bounds directory entry controls 1MB of virtual address
		 * space.  This variable is the virtual address in the process
		 * of the beginning of the area controlled by this bounds_dir.
		 */
		bd_for_vaddr = bd_index * (1UL<<20);

		nr_entries = dump_table(bounds_dir_entry, bd_for_vaddr,
				bounds_dir_global+bd_offset_bytes+i);
		total_entries += nr_entries;
		dprintf5("dir entry[%4ld @ %p]: 0x%lx %6d entries "
			 "total this buf: %7d bd_for_vaddrs: 0x%lx -> 0x%lx\n",
				bd_index, buf+i,
				bounds_dir_entry, nr_entries, total_entries,
				bd_for_vaddr, bd_for_vaddr + (1UL<<20));
	}
	dprintf3("%s(%p, %x, %lx, ...) done\n", __func__, buf, len_bytes,
			bd_offset_bytes);
	return total_entries;
}
Exemple #15
0
 BOOL StartTransfer(BOOL InputOrOutput, BOOL NewAuto)
 {
     PBYTE DMATransferAddress;

    /*
     *  Set the status to see if more apps will work
     */

     WriteStatus = 0xFF;

    /*
     *  We find where the data is - we know how long it is from
     *  the block size
     */

     DMATransferAddress = GetTransferAddress();

     dprintf2(("Starting transfer from %8X", (DWORD)DMATransferAddress));

     if (DMATransferAddress == (PBYTE)(-1L)) {
         return FALSE;
     }

#if DBG

     if (VddDebugLevel >= 3) {
         int i;
         for (i = 0; i < 64; i+= 8) {
             dprintf(("Data : %2X %2X %2X %2X %2X %2X %2X %2X",
                      ((PBYTE)DMATransferAddress)[i],
                      ((PBYTE)DMATransferAddress)[i + 1],
                      ((PBYTE)DMATransferAddress)[i + 2],
                      ((PBYTE)DMATransferAddress)[i + 3],
                      ((PBYTE)DMATransferAddress)[i + 4],
                      ((PBYTE)DMATransferAddress)[i + 5],
                      ((PBYTE)DMATransferAddress)[i + 6],
                      ((PBYTE)DMATransferAddress)[i + 7]));
         }
     }

#endif //DBG

    /*
     *  If we're changing our type of device
     */

     if (InputOrOutput != Input) {

         dprintf3(("Direction changed - close device"));
         CloseWaveDevice();
         Input = InputOrOutput;
     }
    /*
     *  Start the device if possible
     */

     KillWaveDevice();

     Auto = NewAuto;

     if (Auto) {
         BlockSize /= 2;
     }

     if (SetupWave(DMATransferAddress)) {
        /*
         *  Set the device as requesting
         */

         SetTerminalCount(TRUE);
     }
 }
Exemple #16
0
NTSTATUS
sndCreate(
    IN OUT PLOCAL_DEVICE_INFO pLDI
)
/*++

Routine Description:

    Create call (for FILE_WRITE_DATA access).  Read access is granted to
    anyone in dispatch.c.

Arguments:

    pLDI - our local device into

Return Value:

    STATUS_SUCCESS if OK or
    STATUS_BUSY    if someone else has the device


--*/
{
    NTSTATUS Status;
    PGLOBAL_DEVICE_INFO pGDI;

    pGDI = (PGLOBAL_DEVICE_INFO)pLDI->pGlobalInfo;
    //
    // Acquire the spin lock
    //

    GlobalEnter(pLDI->pGlobalInfo)

     if (pLDI->DeviceType == WAVE_IN || pLDI->DeviceType == WAVE_OUT) {

        //
        // The other 3 devices share the interrupt
        //

        if (pLDI->pGlobalInfo->Usage != SoundInterruptUsageIdle) {

            dprintf1("Attempt to open device while busy");
            Status = STATUS_DEVICE_BUSY;

        } else {

            ASSERT(pLDI->pGlobalInfo->pIrpPause == NULL &&
                   pLDI->State == 0 &&
                   IsListEmpty(&pLDI->QueueHead));


            pLDI->pGlobalInfo->DMABuffer[0].nBytes = 0;
            pLDI->pGlobalInfo->DMABuffer[1].nBytes = 0;
            pLDI->SampleNumber = 0;

            //
            // Initialize state data and interrupt usage for
            // the chosen device type
            //

            switch (pLDI->DeviceType) {
            case WAVE_IN:

                pLDI->pGlobalInfo->Usage = SoundInterruptUsageWaveIn;
                pLDI->pGlobalInfo->SamplesPerSec = WAVE_INPUT_DEFAULT_RATE;
                pLDI->State = WAVE_DD_STOPPED;

                //
                // Set the input source
                //

                sndSetInputVolume(pGDI);
                dprintf3("Opened for wave input");

                Status = STATUS_SUCCESS;
                break;

            case WAVE_OUT:

                ASSERT(IsListEmpty(&pLDI->TransitQueue) &&
                IsListEmpty(&pLDI->DeadQueue));

                pLDI->pGlobalInfo->Usage = SoundInterruptUsageWaveOut;
                pLDI->pGlobalInfo->SamplesPerSec = WAVE_OUTPUT_DEFAULT_RATE;
                pLDI->State = WAVE_DD_PLAYING;

                dprintf3("Opened for wave output");

                Status = STATUS_SUCCESS;
                break;

            default:

                Status = STATUS_INTERNAL_ERROR;
                break;
            }

            if (Status == STATUS_SUCCESS) {
                ASSERT(!pLDI->DeviceBusy);
                pLDI->DeviceBusy = TRUE;
            }
        }
    } else {
        Status = STATUS_INTERNAL_ERROR;
    }

    //
    // Release the spin lock
    //
    GlobalLeave(pLDI->pGlobalInfo)

    return Status;
}
Exemple #17
0
int dump_table(unsigned long table_vaddr, unsigned long base_controlled_vaddr,
		unsigned long bde_vaddr)
{
	unsigned long offset_inside_bt;
	int nr_entries = 0;
	int do_abort = 0;
	char *bt_buf;

	dprintf3("%s() base_controlled_vaddr: 0x%012lx bde_vaddr: 0x%012lx\n",
			__func__, base_controlled_vaddr, bde_vaddr);

	bt_buf = read_bounds_table_into_buf(table_vaddr);

	dprintf4("%s() read done\n", __func__);

	for (offset_inside_bt = 0;
	     offset_inside_bt < MPX_BOUNDS_TABLE_SIZE_BYTES;
	     offset_inside_bt += bt_entry_size_bytes) {
		unsigned long bt_entry_index;
		unsigned long bt_entry_controls;
		unsigned long this_bt_entry_for_vaddr;
		unsigned long *bt_entry_buf;
		int i;

		dprintf4("%s() offset_inside_bt: 0x%lx of 0x%llx\n", __func__,
			offset_inside_bt, MPX_BOUNDS_TABLE_SIZE_BYTES);
		bt_entry_buf = (void *)&bt_buf[offset_inside_bt];
		if (!bt_buf) {
			printf("null bt_buf\n");
			mpx_dig_abort();
		}
		if (!bt_entry_buf) {
			printf("null bt_entry_buf\n");
			mpx_dig_abort();
		}
		dprintf4("%s() reading *bt_entry_buf @ %p\n", __func__,
				bt_entry_buf);
		if (!bt_entry_buf[0] &&
		    !bt_entry_buf[1] &&
		    !bt_entry_buf[2] &&
		    !bt_entry_buf[3])
			continue;

		nr_entries++;

		bt_entry_index = offset_inside_bt/bt_entry_size_bytes;
		bt_entry_controls = sizeof(void *);
		this_bt_entry_for_vaddr =
			base_controlled_vaddr + bt_entry_index*bt_entry_controls;
		/*
		 * We sign extend vaddr bits 48->63 which effectively
		 * creates a hole in the virtual address space.
		 * This calculation corrects for the hole.
		 */
		if (this_bt_entry_for_vaddr > 0x00007fffffffffffUL)
			this_bt_entry_for_vaddr |= 0xffff800000000000;

		if (!vaddr_mapped_by_range(this_bt_entry_for_vaddr)) {
			printf("bt_entry_buf: %p\n", bt_entry_buf);
			printf("there is a bte for %lx but no mapping\n",
					this_bt_entry_for_vaddr);
			printf("	  bde   vaddr: %016lx\n", bde_vaddr);
			printf("base_controlled_vaddr: %016lx\n", base_controlled_vaddr);
			printf("	  table_vaddr: %016lx\n", table_vaddr);
			printf("	  entry vaddr: %016lx @ offset %lx\n",
				table_vaddr + offset_inside_bt, offset_inside_bt);
			do_abort = 1;
			mpx_dig_abort();
		}
		if (DEBUG_LEVEL < 4)
			continue;

		printf("table entry[%lx]: ", offset_inside_bt);
		for (i = 0; i < bt_entry_size_bytes; i += sizeof(unsigned long))
			printf("0x%016lx ", bt_entry_buf[i]);
		printf("\n");
	}
	if (do_abort)
		mpx_dig_abort();
	dprintf4("%s() done\n",  __func__);
	return nr_entries;
}
Exemple #18
0
 void MyByteOut(WORD port, BYTE data)
 {
     dprintf3(("Received write to Port %4X, Data %2X", port, data));

     switch (port - BasePort) {
     case RESET_PORT:
         if (data == 1) {
             ResetState = Reset1Written;
         } else {
             if (ResetState == Reset1Written && data == 0) {
                 ResetState = ResetNotStarted;

                /*
                 *  OK - reset everything
                 */

                 CloseWaveDevice();

                /*
                 *  Reset state machines
                 */

                 DSPReadState = Reset;
                 DSPWriteState = WriteCommand;
                 GetVersionFirst = TRUE;
             }
         }
         break;

     case WRITE_PORT:
        /*
         *  Use the state to see if it's data
         */


         switch (DSPWriteState) {
         case WriteCommand:
             WriteCommandByte(data);
             break;

         case CardIdent:
             IdentByte = data;
             DSPReadState = ReadIdent;
             DSPWriteState = WriteCommand;
             break;

         case SetTimeConstant:
             TimeConstant =  (DWORD)data;
             dprintf2(("Set sampling rate %d", GetSamplingRate()));
             DSPWriteState = WriteCommand;
             break;

         case BlockSizeFirstByte:
             SBBlockSize = (DWORD)data;
             DSPWriteState = BlockSizeSecondByte;
             break;

         case BlockSizeSecondByte:
             SBBlockSize = SBBlockSize + ((DWORD)data << 8) + 1;
             DSPWriteState = WriteCommand;
             dprintf2(("Block size set to 0x%x", SBBlockSize));
             break;

         case BlockSizeFirstByteWrite:
             SBBlockSize = (DWORD)data;
             DSPWriteState = BlockSizeSecondByteWrite;
             break;

         case BlockSizeSecondByteWrite:
             SBBlockSize = SBBlockSize + ((DWORD)data << 8) + 1;
             DSPWriteState = WriteCommand;
             StartTransfer(FALSE, FALSE);
             break;

         case BlockSizeFirstByteRead:
             SBBlockSize = (DWORD)data;
             DSPWriteState = BlockSizeSecondByteRead;
             break;

         case BlockSizeSecondByteRead:
             SBBlockSize = SBBlockSize + ((DWORD)data << 8) + 1;
             DSPWriteState = WriteCommand;
             StartTransfer(TRUE, FALSE);
             break;

         case DirectWaveOut:
         case MidiWrite:
            /*
             *  Just discard for now
             */
             DSPWriteState = WriteCommand;
             break;

         }
         break;

     }
 }
Exemple #19
0
NTSTATUS
sndClose(
    IN OUT PLOCAL_DEVICE_INFO pLDI
)
/*++

Routine Description:

    Close the requested device

        Note - we close immediately, there is no waiting for the device.

Arguments:

    pLDI - pointer to our local device info

Return Value:

    STATUS_SUCCESS        if OK otherwise
    STATUS_INTERNAL_ERROR

--*/
{
    NTSTATUS Status = STATUS_SUCCESS;
    PGLOBAL_DEVICE_INFO pGDI;

    pGDI = pLDI->pGlobalInfo;

    //
    // Acquire the spin lock
    //

    GlobalEnter(pGDI)


    //
    // Call the device reset function to complete any
    // pending i/o requests and terminate any current
    // requests in progress
    //

    switch (pLDI->DeviceType) {
    case WAVE_IN:
    case WAVE_OUT:

        //
        // Check this is valid call
        //
        ASSERT(pLDI->DeviceBusy == 2);

        pGDI->Usage = SoundInterruptUsageIdle;
        if (pLDI->DeviceType) {

            //
            // Restore the line in input if necessary
            //

            sndSetInputVolume(pGDI);
        }
        break;

    default:
        dprintf1("Bogus device type for close request");
        Status = STATUS_INTERNAL_ERROR;
        break;
    }

    //
    // return the device to it's idle state
    //

    if (Status == STATUS_SUCCESS) {
        pLDI->DeviceBusy = FALSE;
        dprintf3("Device closed");
    }

#ifdef MIPSSND_TAIL_BUG

    // Since the Device is now closed we can set the Output Volume
    // just in case someone wants to play CDs or listen to Linein

    sndSetOutputVolume( pGDI );

#endif // MIPSSND_TAIL_BUG

    //
    // Release the spin lock
    //

    GlobalLeave(pGDI);

    return Status;
}
Exemple #20
0
/* Default implementation of tile_rectangle */
int
gx_default_tile_rectangle(gx_device *dev, register const gx_bitmap *tile,
  int x, int y, int w, int h, gx_color_index color0, gx_color_index color1,
  int px, int py)
{	/* Fill the rectangle in chunks */
	int width = tile->size.x;
	int height = tile->size.y;
	int raster = tile->raster;
	int rwidth = tile->rep_width;
	int irx = ((rwidth & (rwidth - 1)) == 0 ?	/* power of 2 */
		(x + px) & (rwidth - 1) :
		(x + px) % rwidth);
	int ry = (y + py) % tile->rep_height;
	int icw = width - irx;
	int ch = height - ry;
	byte *row = tile->data + ry * raster;
#define d_proc_mono (dev->procs->copy_mono)
	dev_proc_copy_mono((*proc_mono));
#define d_proc_color (dev->procs->copy_color)
	dev_proc_copy_color((*proc_color));
#define d_color_halftone\
		(color0 == gx_no_color_index && color1 == gx_no_color_index)
	int color_halftone;
#define get_color_info()\
  if ( (color_halftone = d_color_halftone) ) proc_color = d_proc_color;\
  else proc_mono = d_proc_mono
	int code;
#ifdef DEBUG
if ( gs_debug['t'] )
   {	int ptx, pty;
	const byte *ptp = tile->data;
	dprintf3("[t]tile %dx%d raster=%d;",
		tile->size.x, tile->size.y, tile->raster);
	dprintf6(" x,y=%d,%d w,h=%d,%d p=%d,%d\n",
		x, y, w, h, px, py);
	for ( pty = 0; pty < tile->size.y; pty++ )
	   {	dprintf("   ");
		for ( ptx = 0; ptx < tile->raster; ptx++ )
			dprintf1("%3x", *ptp++);
	   }
	dputc('\n');
   }
#endif
#define real_copy_tile(srcx, tx, ty, tw, th)\
  code =\
    (color_halftone ?\
     (*proc_color)(dev, row, srcx, raster, gx_no_bitmap_id, tx, ty, tw, th) :\
     (*proc_mono)(dev, row, srcx, raster, gx_no_bitmap_id, tx, ty, tw, th, color0, color1));\
  gp_check_interrupts();\
  if ( code < 0 ) return_error(code)
#ifdef DEBUG
#define copy_tile(sx, tx, ty, tw, th)\
  if ( gs_debug['t'] )\
	dprintf5("   copy sx=%d x=%d y=%d w=%d h=%d\n",\
		 sx, tx, ty, tw, th);\
  real_copy_tile(sx, tx, ty, tw, th)
#else
#define copy_tile(sx, tx, ty, tw, th)\
  real_copy_tile(sx, tx, ty, tw, th)
#endif
	if ( icw >= w )
	   {	/* Narrow operation */
		int ey, fey, cy;
		if ( ch >= h )
		   {	/* Just one (partial) tile to transfer. */
#define color_halftone d_color_halftone
#define proc_color d_proc_color
#define proc_mono d_proc_mono
			copy_tile(irx, x, y, w, h);
#undef proc_mono
#undef proc_color
#undef color_halftone
			return 0;
		   }
		get_color_info();
		ey = y + h;
		fey = ey - height;
		copy_tile(irx, x, y, w, ch);
		cy = y + ch;
		row = tile->data;
		do
		   {	ch = (cy > fey ? ey - cy : height);
			copy_tile(irx, x, cy, w, ch);
		   }
		while ( (cy += ch) < ey );
		return 0;
	   }
	get_color_info();
	if ( ch >= h )
	   {	/* Shallow operation */
		int ex = x + w;
		int fex = ex - width;
		int cx = x + icw;
		copy_tile(irx, x, y, icw, h);
		while ( cx <= fex )
		   {	copy_tile(0, cx, y, width, h);
			cx += width;
		   }
		if ( cx < ex )
		   {	copy_tile(0, cx, y, ex - cx, h);
		   }
	   }
	else
	   {	/* Full operation */
		int ex = x + w, ey = y + h;
		int fex = ex - width, fey = ey - height;
		int cx, cy;
		for ( cy = y; ; )
		   {	copy_tile(irx, x, cy, icw, ch);
			cx = x + icw;
			while ( cx <= fex )
			   {	copy_tile(0, cx, cy, width, ch);
				cx += width;
			   }
			if ( cx < ex )
			   {	copy_tile(0, cx, cy, ex - cx, ch);
			   }
			if ( (cy += ch) >= ey ) break;
			ch = (cy > fey ? ey - cy : height);
			row = tile->data;
		   }
	   }
#undef copy_tile
#undef real_copy_tile
	return 0;
}
Exemple #21
0
NTSTATUS
SoundMixerInit(
    PLOCAL_DEVICE_INFO       pLDI,
    PMIXER_REGISTRY_DATA     SavedControlData,
    BOOLEAN                  MixerSettingsFound
)
{
    int i, SetIndex;
    PLOCAL_MIXER_DATA LocalMixerData;
    PGLOBAL_DEVICE_INFO pGDI;
    PMIXER_INFO MixerInfo;

    pGDI           = pLDI->pGlobalInfo;
    MixerInfo      = &pGDI->MixerInfo;
    LocalMixerData = &pGDI->LocalMixerData;

    /*
    **  Avoid assertions by properly entering the mixer
    */


    /*
    **  Pick up the correct mixer type
    */
    if (SB1(&pGDI->Hw)) {
        return STATUS_SUCCESS;
    }

    KeWaitForSingleObject(&pGDI->DeviceMutex,
                          Executive,
                          KernelMode,
                          FALSE,         // Not alertable
                          NULL);

#ifdef SB_CD
    if (pGDI->Hw.SBCDBase) {
        SBCDMixerInit(pGDI);
    } else
#endif // SB_CD
    {
        if (SBPRO(&pGDI->Hw)) {
            SBPROMixerInit(pGDI);
        } else {
            ASSERT(SB16(&pGDI->Hw));
            SB16MixerInit(pGDI);
        }
    }

    ASSERT(LocalMixerData->NumberOfControls <= MAXCONTROLS);
    ASSERT(LocalMixerData->NumberOfLines <= MAXLINES);
    ASSERT(LocalMixerData->MaxSettableItems <= MAXSETTABLECONTROLS);

    /*
    **  Check the saved data matches
    */

    if (MixerSettingsFound) {
        dprintf3(("Saved mixer settings: Version = %x, DSPVersion = %x, NumberOfControls = %d",
                  SavedControlData->MixerVersion,
                  SavedControlData->DSPVersion,
                  SavedControlData->NumberOfControls));

        if (SavedControlData->MixerVersion     != DRIVER_VERSION ||
            SavedControlData->DSPVersion       != pGDI->Hw.DSPVersion ||
            SavedControlData->NumberOfControls !=
                LocalMixerData->MaxSettableItems) {

            dprintf1(("Saved mixer settings incompatible"));
            MixerSettingsFound = FALSE;
        }
    }

    /*
    **  Init the generic mixer stuff first so we can use it
    */

    SoundInitMixerInfo(&pGDI->MixerInfo,
                       HwGetLineFlags,
                       HwGetControl,
                       HwGetCombinedControl,
                       HwSetControl);

    /*
    **  Get to a known state - this is common to ALL mixers
    **  Detecting the SBCD mixer involves resetting it however.
    */

#ifdef SB_CD
    if (pGDI->Hw.SBCDBase == NULL) {
        dspWriteMixer(pGDI, MIX_RESET_REG, 0);
    }
#endif // SB_CD

    /*
    **  Set this device up with its mixer data
    */
    pLDI->DeviceType         = MIXER_DEVICE;
    pLDI->DeviceSpecificData = (PVOID)MixerInfo;

    /*
    ** Make sure everyone can find the mixer device
    */

    {
        PDEVICE_OBJECT pDO;
        PLOCAL_DEVICE_INFO pLDIDev;

        for (pDO = pGDI->DeviceObject[WaveInDevice]->DriverObject->DeviceObject;
             pDO != NULL;
             pDO = pDO->NextDevice) {


            pLDIDev = (PLOCAL_DEVICE_INFO)pDO->DeviceExtension;

            /*
            **  For multiple cards the following test may fail
            */

            if (pLDIDev->pGlobalInfo == pGDI ||
                pDO == pGDI->Synth.DeviceObject) {
                pLDIDev->MixerDevice = pLDI;
            }
        }
    }


    /*
    **  Create control info
    */

    for (i = 0, SetIndex = 0; i < LocalMixerData->NumberOfControls ; i++) {

        /*
        **  Read limits
        */

        if ((LocalMixerData->MixerControlInit[i].dwControlType & MIXERCONTROL_CT_UNITS_MASK) ==
                MIXERCONTROL_CT_UNITS_SIGNED) {

            pGDI->LocalMixerData.ControlInfo[i].Signed = TRUE;
            pGDI->LocalMixerData.ControlInfo[i].Range.Min.s =
                (SHORT)LocalMixerData->MixerControlInit[i].Bounds.lMinimum;
            pGDI->LocalMixerData.ControlInfo[i].Range.Max.s =
                (SHORT)LocalMixerData->MixerControlInit[i].Bounds.lMaximum;
        } else {

            if ((LocalMixerData->MixerControlInit[i].dwControlType & MIXERCONTROL_CT_UNITS_MASK) ==
                     MIXERCONTROL_CT_UNITS_BOOLEAN) {
                pGDI->LocalMixerData.ControlInfo[i].Boolean = TRUE;
            }
            pGDI->LocalMixerData.ControlInfo[i].Range.Min.u =
                (USHORT)LocalMixerData->MixerControlInit[i].Bounds.dwMinimum;
            pGDI->LocalMixerData.ControlInfo[i].Range.Max.u =
                (USHORT)LocalMixerData->MixerControlInit[i].Bounds.dwMaximum;
        }

        /*
        **  Remember if it's a mux and tot up text items
        */

        if (LocalMixerData->MixerControlInit[i].dwControlType == MIXERCONTROL_CONTROLTYPE_MIXER ||
            LocalMixerData->MixerControlInit[i].dwControlType == MIXERCONTROL_CONTROLTYPE_MUX) {
            pGDI->LocalMixerData.ControlInfo[i].Mux = TRUE;

            LocalMixerData->NumberOfTextItems +=
                (UCHAR)LocalMixerData->MixerControlInit[i].cMultipleItems;

            ASSERT(LocalMixerData->MixerControlInit[i].cMultipleItems <=
                   MAXITEMS);
        }

        /*
        **  Only meters are not settable here
        */

        if ((LocalMixerData->MixerControlInit[i].dwControlType & MIXERCONTROL_CT_CLASS_MASK) !=
            MIXERCONTROL_CT_CLASS_METER)
        {
            LocalMixerData->ControlInfo[i].SetIndex = (UCHAR)SetIndex;
            SoundInitDataItem(MixerInfo,
                              &LocalMixerData->ControlNotification[SetIndex],
                              (USHORT)MM_MIXM_CONTROL_CHANGE,
                              (USHORT)i);
            if (MixerSettingsFound) {

                    /*
                    **  What if it's invalid?
                    */

                LocalMixerData->ControlInfo[i].Data =
                    SavedControlData->ControlData[SetIndex];
            }
            SetIndex++;
        } else {
            LocalMixerData->ControlInfo[i].SetIndex = MIXER_SET_INDEX_INVALID;
        }
    }

    ASSERTMSG("MaxSettableItems wrong!",
              SetIndex == LocalMixerData->MaxSettableItems);

    /*
    **  Create line info
    */

    for (i = 0; i < LocalMixerData->NumberOfLines; i++) {
        SoundInitDataItem(MixerInfo,
                          &pGDI->LocalMixerData.LineNotification[i],
                          (USHORT)MM_MIXM_LINE_CHANGE,
                          (USHORT)i);
    }

    /*
    **  Set everything up.
    */

    for (i = 0; i < LocalMixerData->NumberOfControls; i++) {
        SoundMixerSet(pGDI, i);
    }

    KeReleaseMutex(&pGDI->DeviceMutex, FALSE);

    return STATUS_SUCCESS;
}
Exemple #22
0
/*****************************************************************************

Routine Description :

    Return configuration information for our device

Arguments :

    ConfigData - where to store the result

Return Value :

    NT status code - STATUS_SUCCESS if no problems

*****************************************************************************/
NTSTATUS    SoundReadConfiguration( IN  PWSTR ValueName,
                                 IN  ULONG ValueType,
                                 IN  PVOID ValueData,
                                 IN  ULONG ValueLength,
                                 IN  PVOID Context,
                                 IN  PVOID EntryContext )
{
        /***** Local Variables *****/

    PPAS_CONFIG_DATA    ConfigData;

                /***** Start *****/

    dprintf4(("SoundReadConfiguration(): Start"));

    ConfigData = Context;

    if ( ValueType == REG_DWORD )
        {
        // Base I/O Port
        if ( _wcsicmp(ValueName, SOUND_REG_PORT)  == 0 )
            {
            ConfigData->Port = *(PULONG)ValueData;
            dprintf3((" SoundReadConfiguration(): Read Port Base       = %XH",
                                                 ConfigData->Port));
            }

        // Interrupt
        else if ( _wcsicmp(ValueName, SOUND_REG_INTERRUPT)  == 0 )
            {
            ConfigData->InterruptNumber = *(PULONG)ValueData;
            dprintf3((" SoundReadConfiguration(): Read Interrupt       = %u",
                                                 ConfigData->InterruptNumber));
            }

        // DMA Channel
        else if ( _wcsicmp(ValueName, SOUND_REG_DMACHANNEL)  == 0 )
            {
            ConfigData->DmaChannel = *(PULONG)ValueData;
            dprintf3((" SoundReadConfiguration(): Read DMA Channel     = %u",
                                                 ConfigData->DmaChannel));
            }

        // DMA Buffer Size
        else if ( _wcsicmp(ValueName, SOUND_REG_DMABUFFERSIZE )  == 0 )
            {
            ConfigData->DmaBufferSize = *(PULONG)ValueData;
            dprintf3((" SoundReadConfiguration(): Read DMA Buffer Size = %XH",
                                                 ConfigData->DmaBufferSize));
            }

        // FM Clock Override
        else if ( _wcsicmp(ValueName, SOUND_REG_FM_CLK_OVRID)  == 0 )
            {
            ConfigData->FMClockOverride = *(PULONG)ValueData;
            dprintf3((" SoundReadConfiguration(): Read FMClockOverride = %u",
                                                 ConfigData->FMClockOverride));
            }
        else if ( _wcsicmp(ValueName, SOUND_REG_ALLOWMICLINEINTOLINEOUT)  == 0 )
            {
            ConfigData->AllowMicOrLineInToLineOut = (BOOLEAN)(*(PULONG)ValueData != 0);
            dprintf3((" SoundReadConfiguration(): Read FMClockOverride = %u",
                                                 ConfigData->FMClockOverride));
            }

        // Input Source
        else if ( _wcsicmp(ValueName, SOUND_REG_INPUTSOURCE)  == 0 )
            {
            ConfigData->InputSource = *(PULONG)ValueData;
            dprintf3((" SoundReadConfiguration() Read Input Source     = %s",
                       ConfigData->InputSource == INPUT_LINEIN ? "Line in" :
                       ConfigData->InputSource == INPUT_AUX ? "Aux" :
                       ConfigData->InputSource == INPUT_MIC ? "Microphone" :
                       ConfigData->InputSource == INPUT_OUTPUT ? "Output" :
                      "Invalid input source" ));
            }
        }           // End IF (ValueType == REG_DWORD)
     else {
        if (ValueType == REG_BINARY &&
            _wcsicmp(ValueName, SOUND_MIXER_SETTINGS_NAME) == 0) {
            ASSERTMSG("Mixer data wrong length!",
                      ValueLength == sizeof(ConfigData->MixerSettings));

            dprintf3(("Mixer settings"));
            RtlCopyMemory((PVOID)ConfigData->MixerSettings,
                          ValueData,
                          ValueLength);
            ConfigData->MixerSettingsFound = TRUE;
        }
    }

    return STATUS_SUCCESS;

}
Exemple #23
0
/*
 * Look up a name on the dictionary stack.
 * Return the pointer to the value if found, 0 if not.
 */
ref *
dstack_find_name_by_index(dict_stack_t * pds, uint nidx)
{
    ds_ptr pdref = pds->stack.p;

/* Since we know the hash function is the identity function, */
/* there's no point in allocating a separate variable for it. */
#define hash dict_name_index_hash(nidx)
    ref_packed kpack = packed_name_key(nidx);

    do {
	dict *pdict = pdref->value.pdict;
	uint size = npairs(pdict);
	const gs_memory_t *mem = dict_mem(pdict);
#ifdef DEBUG
	if (gs_debug_c('D')) {
	    ref dnref;

	    name_index_ref(mem, nidx, &dnref);
	    dlputs("[D]lookup ");
	    debug_print_name(mem, &dnref);
	    dprintf3(" in 0x%lx(%u/%u)\n",
		     (ulong) pdict, dict_length(pdref),
		     dict_maxlength(pdref));
	}
#endif
#define INCR_DEPTH(pdref)\
  INCR(depth[min(MAX_STATS_DEPTH, pds->stack.p - pdref)])
	if (dict_is_packed(pdict)) {
	    packed_search_1(INCR_DEPTH(pdref),
			    return packed_search_value_pointer,
			    DO_NOTHING, goto miss);
	    packed_search_2(INCR_DEPTH(pdref),
			    return packed_search_value_pointer,
			    DO_NOTHING, break);
	  miss:;
	} else {
	    ref *kbot = pdict->keys.value.refs;
	    register ref *kp;
	    int wrap = 0;

	    /* Search the dictionary */
	    for (kp = kbot + dict_hash_mod(hash, size) + 2;;) {
		--kp;
		if (r_has_type(kp, t_name)) {
		    if (name_index(mem, kp) == nidx) {
			INCR_DEPTH(pdref);
			return pdict->values.value.refs + (kp - kbot);
		    }
		} else if (r_has_type(kp, t_null)) {	/* Empty, deleted, or wraparound. */
		    /* Figure out which. */
		    if (!r_has_attr(kp, a_executable))
			break;
		    if (kp == kbot) {	/* wrap */
			if (wrap++)
			    break;	/* 2 wraps */
			kp += size + 1;
		    }
		}
	    }
	}
#undef INCR_DEPTH
    }
Exemple #24
0
 BOOL SetupWave(PVOID TransferAddress)
 {
      DWORD SampleRate;
      UINT rc;

     /*
      *  Make sure we've got a device - we may have one which does
      *  not match the current sampling rate.
      */

      if (TimeConstant != 0xFFFF) {
          SampleRate = GetSamplingRate();
          if (SampleRate != WaveFormat.wf.nSamplesPerSec) {

               /*
                *  Search for a suitable format
                */

                if (!TestWaveFormat(SampleRate)) {
                    /*
                     *  If this did not work it may be too fast
                     *  or slow so move it into our compass
                     */

                     if (SampleRate > 22050) {
                         SampleRate = 22050;
                     } else {
                         if (SampleRate < 11025) {
                             SampleRate = 11025;
                         }
                     }

                    /*
                     *  Device may only support discrete rates
                     */

                     if (!TestWaveFormat(SampleRate)) {
                         if (SampleRate > (11025 + 22050) / 2) {
                             SampleRate == 22050;
                         } else {
                             SampleRate = 11025;
                         }
                     }
                }

               /*
                *  Open the device with the new format if it's changed
                */

                if (SampleRate != WaveFormat.wf.nSamplesPerSec) {

                    dprintf3(("Format changed"));

                    CloseWaveDevice();

                    WaveFormat.wf.nSamplesPerSec = SampleRate;
                    WaveFormat.wf.nAvgBytesPerSec = SampleRate;

                    dprintf2(("Setting %d samples per second", SampleRate));

                }
          }
          TimeConstant = 0xFFFF;
      }

      if (hWave == NULL) {
          dprintf3(("Opening wave device"));
          OpenWaveDevice();
      } else {

          dprintf3(("Resetting wave device prior to play"));
          (Input ? waveInReset : waveOutReset)(hWave);
      }

     /*
      *  Set up any wave buffers etc if necessary
      */

      if (hWave) {
          if (WaveHdr[0].lpData != (LPSTR)TransferAddress ||
              BlockSize != WaveHdr[0].dwBufferLength) {

              (Input ? waveInUnprepareHeader : waveOutUnprepareHeader)
                  (hWave, &WaveHdr[0], sizeof(WAVEHDR));

              if (WaveHdr[1].dwFlags & WHDR_PREPARED) {
                  (Input ? waveInUnprepareHeader : waveOutUnprepareHeader)
                      (hWave, &WaveHdr[1], sizeof(WAVEHDR));
              }

          }

          WaveHdr[0].lpData = (LPSTR)TransferAddress;
          WaveHdr[0].dwBufferLength = BlockSize;
          WaveHdr[1].lpData = (LPSTR)TransferAddress + BlockSize;
          WaveHdr[1].dwBufferLength = BlockSize;

          if (Auto && AutoThread == NULL) {

              dprintf3(("Creating event"));

              if (AutoEvent == NULL) {
                  AutoEvent = CreateEvent(NULL, 0, 0, NULL);

                  if (AutoEvent != NULL) {
                      DWORD Id;

                      dprintf2(("Creating thread"));

                      AutoThread = CreateThread(NULL,
                                                300,
                                                AutoThreadEntry,
                                                NULL,
                                                0,
                                                &Id);
                      if (AutoThread == NULL) {
                          dprintf2(("Create thread failed code %d",
                                   GetLastError()));
                      }
                  } else {
                      dprintf2(("Create event failed code %d",
                               GetLastError()));
                  }
              }
          }

          if (!(WaveHdr[0].dwFlags & WHDR_PREPARED)) {

              (Input ? waveInPrepareHeader : waveOutPrepareHeader)
                  (hWave, &WaveHdr[0], sizeof(WAVEHDR));
          }

          if (Auto) {
              if (!(WaveHdr[1].dwFlags & WHDR_PREPARED)) {
                  (Input ? waveInPrepareHeader : waveOutPrepareHeader)
                      (hWave, &WaveHdr[1], sizeof(WAVEHDR));
              }
          }

         /*
          *  Actually do it!
          */

          dprintf2(("Writing %d bytes to wave device",
                    WaveHdr[0].dwBufferLength));

          rc = (Input ? waveInAddBuffer : waveOutWrite)
                  (hWave, &WaveHdr[0], sizeof(WAVEHDR));

          if (rc != MMSYSERR_NOERROR) {
              dprintf1(("Failed to write to /read from wave device - %d", rc));
          }

          if (Auto) {
              (Input ? waveInAddBuffer : waveOutWrite)
                  (hWave, &WaveHdr[1], sizeof(WAVEHDR));
          }

          if (Input) {
              waveInStart(hWave);
          }
      }

      return TRUE;
 }
Exemple #25
0
/* Look up a font. */
static gx_xfont *
x_lookup_font(gx_device * dev, const byte * fname, uint len,
	    int encoding_index, const gs_uid * puid, const gs_matrix * pmat,
	      gs_memory_t * mem)
{
    gx_device_X *xdev = (gx_device_X *) dev;
    x_xfont *xxf;
    char x11template[256];
    char *x11fontname = NULL;
    XFontStruct *x11font;
    x11fontmap *fmp;
    double height;
    int xwidth, xheight, angle;
    Boolean My;
    bool scalable_font;

    if (!xdev->useXFonts)
	return NULL;

    if (pmat->xy == 0 && pmat->yx == 0) {
	xwidth = fabs(pmat->xx * 1000) + 0.5;
	xheight = fabs(pmat->yy * 1000) + 0.5;
	height = fabs(pmat->yy * 1000);
	angle = (pmat->xx > 0 ? 0 : 180);
	My = (pmat->xx > 0 && pmat->yy > 0) || (pmat->xx < 0 && pmat->yy < 0);
    } else if (pmat->xx == 0 && pmat->yy == 0) {
	xwidth = fabs(pmat->xy * 1000) + 0.5;
	xheight = fabs(pmat->yx * 1000) + 0.5;
	height = fabs(pmat->yx * 1000);
	angle = (pmat->yx < 0 ? 90 : 270);
	My = (pmat->yx > 0 && pmat->xy < 0) || (pmat->yx < 0 && pmat->xy > 0);
    } else {
	return NULL;
    }

    /* Don't do very small fonts, where font metrics are way off */
    /* due to rounding and the server does a very bad job of scaling, */
    /* or very large fonts, where we can do just as good a job and */
    /* the server may lock up the entire window system while rasterizing */
    /* the whole font. */
    if (xwidth < min_X_font_size || xwidth > max_X_font_size ||
	xheight < min_X_font_size || xheight > max_X_font_size
	)
	return NULL;

    if (!xdev->useFontExtensions && (My || angle != 0))
	return NULL;

    switch (encoding_index) {
    case 0:
	fmp = find_fontmap(xdev->regular_fonts, fname, len);
	if (fmp == NULL)
	    return NULL;
	x11fontname =
	    find_x_font(xdev, x11template, fmp, "Adobe-fontspecific",
			&fmp->std, xheight, &scalable_font);
	if (!x11fontname) {
	    x11fontname =
		find_x_font(xdev, x11template, fmp, "ISO8859-1",
			    &fmp->iso, xheight, &scalable_font);
	    encoding_index = 1;
	}
	break;
    case 1:
	fmp = find_fontmap(xdev->regular_fonts, fname, len);
	if (fmp == NULL)
	    return NULL;
	x11fontname =
	    find_x_font(xdev, x11template, fmp, "ISO8859-1",
			&fmp->iso, xheight, &scalable_font);
	if (!x11fontname) {
	    x11fontname =
		find_x_font(xdev, x11template, fmp, "Adobe-fontspecific",
			    &fmp->std, xheight, &scalable_font);
	    encoding_index = 0;
	}
	break;
    case 2:
	fmp = xdev->symbol_fonts;
	goto sym;
    case 3:
	fmp = xdev->dingbat_fonts;
sym:	fmp = find_fontmap(fmp, fname, len);
	if (fmp == NULL)
	    return NULL;
	x11fontname =
	    find_x_font(xdev, x11template, fmp, "Adobe-fontspecific",
			&fmp->std, xheight, &scalable_font);
    default:
	return NULL;
    }
    if (!x11fontname)
	return NULL;

    if (xwidth != xheight || angle != 0 || My) {
	if (!xdev->useScalableFonts || !scalable_font)
	    return NULL;
	sprintf(x11template, "%s%s+%d-%d+%d-0-0-0-*-0-%s",
		fmp->x11_name, (My ? "+My" : ""),
		angle * 64, xheight, xwidth,
		(encoding_index == 1 ? "ISO8859-1" : "Adobe-fontspecific"));
	x11fontname = x11template;
    }
    x11font = XLoadQueryFont(xdev->dpy, x11fontname);
    if (x11font == NULL)
	return NULL;
    /* Don't bother with 16-bit or 2 byte fonts yet */
    if (x11font->min_byte1 || x11font->max_byte1) {
	XFreeFont(xdev->dpy, x11font);
	return NULL;
    }
    xxf = gs_alloc_struct(mem, x_xfont, &st_x_xfont, "x_lookup_font");
    if (xxf == NULL)
	return NULL;
    xxf->common.procs = &x_xfont_procs;
    xxf->xdev = xdev;
    xxf->font = x11font;
    xxf->encoding_index = encoding_index;
    xxf->My = (My ? -1 : 1);
    xxf->angle = angle;
    if (xdev->logXFonts) {
	dprintf3("Using %s\n  for %s at %g pixels.\n", x11fontname,
		 fmp->ps_name, height);
	dflush();
    }
    return (gx_xfont *) xxf;
}
Exemple #26
0
NTSTATUS
sndCleanUp(
    IN OUT PLOCAL_DEVICE_INFO pLDI
)
/*++

Routine Description:

    Clean up the requested device

Arguments:

    pLDI - pointer to our local device info

Return Value:

    STATUS_SUCCESS        if OK otherwise
    STATUS_INTERNAL_ERROR

--*/
{
    NTSTATUS Status = STATUS_SUCCESS;
    PGLOBAL_DEVICE_INFO pGDI;

    pGDI = pLDI->pGlobalInfo;

    //
    // Acquire the spin lock
    //

    GlobalEnter(pGDI)

    if (pLDI->DeviceType == WAVE_IN || pLDI->DeviceType == WAVE_OUT) {

        //
        // Check this is valid call
        //

        ASSERT(pLDI->DeviceBusy == TRUE);

        //
        // Call the device reset function to complete any
        // pending i/o requests and terminate any current
        // requests in progress
        //

        switch (pLDI->DeviceType) {

        case WAVE_IN:

            sndStopWaveInput(pLDI);

            //
            // Reset position to start and free any pending Irps.
            //
            sndFreeQ(pLDI, &pLDI->QueueHead, STATUS_CANCELLED);
            pLDI->SampleNumber = 0;

            break;

        case WAVE_OUT:

            //
            // If anything is in the queue then free it.
            // beware that the final block of a request may still be
            // being dma'd when we get this call.  We now kill this as well
            // because we've changed such that the if the application thinks
            // all the requests are complete then they are complete.
            //

            if (pGDI->DMABusy) {

                #ifdef MIPSSND_TAIL_BUG

                //
                // Turn off the headphone and Lineout to avoid end clicks
                //
                sndMute(pGDI);

                // We could also mute by turning of the headphone
                // But mute using volume "sounds" better.
                // sndHeadphoneControl(pGDI, OFF);
                // sndLineoutControl(pGDI, OFF);

                #endif // MIPSSND_TAIL_BUG

                sndStopDMA(pGDI);
            }

            sndResetOutput(pLDI);

            if (pGDI->pIrpPause) {
                pGDI->pIrpPause->IoStatus.Status = STATUS_SUCCESS;
                IoCompleteRequest(pGDI->pIrpPause, IO_SOUND_INCREMENT);
                pGDI->pIrpPause = NULL;
            }

            break;
        }
        //
        // return the device to it's idle state
        //

        if (Status == STATUS_SUCCESS) {
            pLDI->State = 0;
            pLDI->DeviceBusy = 2;
            dprintf3("Device closing");
        }
    }

    if ( pLDI->DeviceType != WAVE_IN && pLDI->DeviceType != WAVE_OUT ){
        dprintf1("Bogus device type for cleanup request");
        Status = STATUS_INTERNAL_ERROR;
    }


#ifdef MIPSSND_TAIL_BUG

    // Since the Device is now closed we can set the Output Volume
    // just in case someone wants to play CDs or listen to Linein

    sndSetOutputVolume( pGDI );

#endif // MIPSSND_TAIL_BUG

    //
    // Release the spin lock
    //

    GlobalLeave(pGDI);

    return Status;
}
Exemple #27
0
VOID SBPROSetADCHardware(PGLOBAL_DEVICE_INFO pGDI)
{
   UCHAR        bSource;
   UCHAR        bNumStepsL, bNumStepsR, bGainL, bGainR, bValue ;
   DWORD        dwDest, dwAGCControlID, dwMixerControlID,
                dwGainControlID, dwVolControlID ;
   UINT         i ;

   dprintf3(( "SBPROSetADCHardware" )) ;

   bSource = 0xFF;

   if (WAVE_IN_ACTIVE(&pGDI->WaveInfo)) {
       if (MixerLineSelected(&pGDI->LocalMixerData, ControlWaveInMux, DestWaveInSourceAux)) {

           bSource = 0x06;

           Set3BitVolume(
               pGDI,
               DSP_MIX_LINEVOLIDX,
               pGDI->LocalMixerData.ControlInfo[ControlWaveInAuxVolume].Data.v[0].u,
               pGDI->LocalMixerData.ControlInfo[ControlWaveInAuxVolume].Data.v[1].u);
       } else

       if (MixerLineSelected(&pGDI->LocalMixerData, ControlWaveInMux, DestWaveInSourceMic)) {

           bSource = 0x00;

           //
           //  No volume to set
           //
       } else

       if (MixerLineSelected(&pGDI->LocalMixerData, ControlWaveInMux, DestWaveInSourceInternal)) {

           bSource = 0x02;

           Set3BitVolume(
               pGDI,
               DSP_MIX_CDVOLIDX,
               pGDI->LocalMixerData.ControlInfo[ControlWaveInInternalCDVolume].Data.v[0].u,
               pGDI->LocalMixerData.ControlInfo[ControlWaveInInternalCDVolume].Data.v[1].u);
       }
   } else {
       if (VOICE_IN_ACTIVE(&pGDI->WaveInfo)) {

           if (pGDI->LocalMixerData.ControlInfo[ControlVoiceInMux].Data.v[0].u ==
               MUXINPUT_AUX1) {

               bSource = 0x06;

               Set3BitVolume(
                   pGDI,
                   DSP_MIX_LINEVOLIDX,
                   pGDI->LocalMixerData.ControlInfo[ControlWaveInAuxVolume].Data.v[0].u,
                   pGDI->LocalMixerData.ControlInfo[ControlWaveInAuxVolume].Data.v[1].u);
           } else {
               bSource = 0x00;
           }
       } else {

           //
           //  Nothing to set
           //
           return;
       }
   }

   ASSERT(bSource != 0xFF);

   //
   //  Select input source
   //

   {
       UCHAR InputSettingRegister;

       InputSettingRegister = dspReadMixer(pGDI, INPUT_SETTING_REG);
       InputSettingRegister &= ~0x06;
       dspWriteMixer(pGDI, INPUT_SETTING_REG,
                     (UCHAR)(InputSettingRegister | bSource));
   }

} // SBPROSetADCHardware()
Exemple #28
0
 void MyByteIn(WORD port, BYTE *data)
 {
     DWORD BytesRead;

    /*
     *  If we fail simulate nothing at the port
     */

     *data = 0xFF;

     switch (port - BasePort) {
     case WRITE_STATUS:

        /*
         *  Can always write
         */

         *data = WriteStatus;
         WriteStatus = 0x7F;
         break;

     case READ_STATUS:
        /*
         *  See if we think there is something to read
         */

         InterruptAcknowleged = TRUE;
         *data = DSPReadState != NothingToRead ? 0xFF : 0x7F;
         break;

     case READ_DATA:
        /*
         *  The only useful things they can read are :
         *     0xAA after RESET
         *
         *     The DSP version
         */

         switch (DSPReadState) {
         case NothingToRead:
             *data = 0xFF;
             break;

         case ReadIdent:
             *data = ~IdentByte;
             DSPReadState = NothingToRead;
             break;

         case Reset:
             *data = 0xAA;
             DSPReadState = NothingToRead;
             break;

         case FirstVersionByte:
             if (GetVersionFirst) {
                 *data = SB_VERSION / 256;
             } else {
                 *data = 0x01;  // Thunderboard version
             }
             DSPReadState = SecondVersionByte;
             break;

         case SecondVersionByte:
             if (GetVersionFirst) {
                 *data = SB_VERSION % 256;
             } else {
                 *data = 0x21;  // Thunderboard version
             }
             GetVersionFirst = FALSE;
             break;
         }
     }

     dprintf3(("Received read from Port %4X, Returned Data %2X", port, *data));

 }
Exemple #29
0
NTSTATUS
SoundReadConfiguration(
    IN  PWSTR ValueName,
    IN  ULONG ValueType,
    IN  PVOID ValueData,
    IN  ULONG ValueLength,
    IN  PVOID Context,
    IN  PVOID EntryContext
)
/*++

Routine Description :

    Return configuration information for our device

Arguments :

    ConfigData - where to store the result

Return Value :

    NT status code - STATUS_SUCCESS if no problems

--*/
{
    PSOUND_CONFIG_DATA ConfigData;

    ConfigData = Context;

    if (ValueType == REG_DWORD) {

        if (_wcsicmp(ValueName, SOUND_REG_PORT)  == 0) {
            ConfigData->Port = *(PULONG)ValueData;
            dprintf3(("Read Port Base : %x", ConfigData->Port));
        }

        else if (_wcsicmp(ValueName, SOUND_REG_INTERRUPT)  == 0) {
            ConfigData->InterruptNumber = *(PULONG)ValueData;
            dprintf3(("Read Interrupt : 0x%x", ConfigData->InterruptNumber));
        }

        else if (_wcsicmp(ValueName, SOUND_REG_DMACHANNEL)  == 0) {
            ConfigData->DmaChannel = *(PULONG)ValueData;
            dprintf3(("Read DMA Channel : %x", ConfigData->DmaChannel));
        }

        else if (_wcsicmp(ValueName, SOUND_REG_DMABUFFERSIZE)  == 0) {
            ConfigData->DmaBufferSize = *(PULONG)ValueData;
            dprintf3(("Read Buffer size : 0x%x", ConfigData->DmaBufferSize));
        }

        else if (_wcsicmp(ValueName, SOUND_REG_SINGLEMODEDMA)  == 0) {
            ConfigData->SingleModeDMA = *(PULONG)ValueData;
            dprintf3(("Read DemandMode : %x", ConfigData->SingleModeDMA));
        }

        else if (_wcsicmp(ValueName, SOUND_REG_INPUTSOURCE)  == 0) {
            ConfigData->InputSource = *(PULONG)ValueData;
            dprintf3(("Read Input Source : %s",
                     ConfigData->InputSource == INPUT_LINEIN ? "Line in" :
                     ConfigData->InputSource == INPUT_AUX ? "Aux" :
                     ConfigData->InputSource == INPUT_MIC ? "Microphone" :
                     ConfigData->InputSource == INPUT_OUTPUT ? "Output" :
                     "Invalid input source"
                     ));
        }
    } else {
        if (ValueType == REG_BINARY &&
            _wcsicmp(ValueName, SOUND_MIXER_SETTINGS_NAME) == 0) {
            ASSERTMSG("Mixer data wrong length!",
                      ValueLength == sizeof(ConfigData->MixerSettings));

            dprintf3(("Mixer settings"));
            RtlCopyMemory((PVOID)ConfigData->MixerSettings,
                          ValueData,
                          ValueLength);
            ConfigData->MixerSettingsFound = TRUE;
        }
    }

    return STATUS_SUCCESS;
}
Exemple #30
0
BOOLEAN SBPROSetVolume
(
    PGLOBAL_DEVICE_INFO pGDI,
    ULONG               ControlId
)
{
    UCHAR                     bNumStepsL, bNumStepsR, bDSPReg ;
    PLOCAL_MIXER_CONTROL_INFO ControlInfo;

    ControlInfo = &pGDI->LocalMixerData.ControlInfo[ControlId];

    dprintf3(("SBPROSetVolume, Control ID = %s, Left = %u, Right = %u",
             ControlNames[ControlId], ControlInfo->Data.v[0].u, ControlInfo->Data.v[1].u));

    if (ControlId != ControlLineoutVolume) {
        //
        //  If it's not an output line call SBPROSetADCVolume
        //

        if (SBPROLineInit[SBPROControlInit[ControlId].LineID].Destination
            != DestLineout) {
            return SBPROSetADCVolume(pGDI, ControlId);
        }


        //
        // If wave input is running we don't want to change the volume on lines
        // which are switched to wave input because these lines have the input
        // volume set
        //


        if (!SBPROMixerOutputFree(pGDI, SBPROControlInit[ControlId].LineID)) {
            return TRUE;
        }
    }

    //
    // Convert to steps of 1.5dB attenuation for the DSP
    //

    bNumStepsL =
       VolLinearToLog( ControlInfo->Data.v[0].u );
    bNumStepsR =
       VolLinearToLog( ControlInfo->Data.v[1].u );

    // Bounding...

    if (bNumStepsL > 0x07)
       bNumStepsL = 0x07 ;

    if (bNumStepsR > 0x07)
       bNumStepsR = 0x07 ;

    // Convert to levels for the SB mixer

    bNumStepsL = (0x07 - bNumStepsL) << 5 ;
    bNumStepsR = (0x07 - bNumStepsR) << 1 ;

    //
    // Check the associated mute... if set, mute the output.
    //

    ASSERT(SBPROControlInit[ControlId + 1].dwControlType ==
           MIXERCONTROL_CONTROLTYPE_MUTE);

    if (ControlInfo[1].Data.v[0].u) {
       bNumStepsL = bNumStepsR = 0 ;
    }

    switch (ControlId)
    {
       case ControlLineoutAuxVolume:
          bDSPReg = DSP_MIX_LINEVOLIDX;
          break ;

       case ControlLineoutWaveoutVolume:

          //
          // Only mess with DAC during playback
          //

          if (!WAVE_OUT_ACTIVE(&pGDI->WaveInfo)) {
              return TRUE;
          }

          bDSPReg = DSP_MIX_VOICEVOLIDX ;
          break ;

       case ControlLineoutMidioutVolume:
          bDSPReg = DSP_MIX_FMVOLIDX ;
          break ;

       case ControlLineoutInternalCDVolume:
          bDSPReg = DSP_MIX_CDVOLIDX;
          break ;

       case ControlLineoutVolume:
          bDSPReg = DSP_MIX_MSTRVOLIDX;
          break ;
    }

    dprintf3(( "bNumStepsL = %02x, bNumStepsR = %02x", bNumStepsL, bNumStepsR )) ;

    dspWriteMixer( pGDI, bDSPReg, (UCHAR)(bNumStepsL | bNumStepsR )) ;

    return TRUE;

} // end of MixSetVolume()