CBgDisp2::CBgDisp2( int resetflag, LPDIRECT3DDEVICE9 pd3dDevice, char* name1, int trans1, char* name2, int trans2, float mvu, float mvv, COLORREF srccolor, int srcisround, float fogdist, UV startuv, UV enduv, int srcfixsize ) { transparent1 = trans1; transparent2 = trans2; uanime = mvu; vanime = mvv; m_fogdist = fogdist; col = srccolor; isround = srcisround; m_startuv = startuv; m_enduv = enduv; fixsize = srcfixsize; pd3dDevice->SetTexture( 0, NULL ); g_curtex0 = NULL; pd3dDevice->SetTexture( 1, NULL ); g_curtex1 = NULL; int ret; float zmax = 0.9999999f; //float zmax = 1.0f; //float zmax = 0.999999999999f; D3DCOLOR curcolor; if( resetflag == 0 ){ ZeroMemory( texname, _MAX_PATH ); ZeroMemory( texname2, _MAX_PATH ); if( name1 && *name1 ){ strcpy_s( texname, _MAX_PATH, name1 ); } if( name2 && *name2 ) strcpy_s( texname2, _MAX_PATH, name2 ); } ZeroMemory( m_tlv1, sizeof( D3DTLVERTEX ) * BGTLVNUM ); ZeroMemory( m_tlv2, sizeof( D3DTLVERTEX2 ) * BGTLVNUM ); curcolor = D3DCOLOR_ARGB( 255, GetRValue(srccolor), GetGValue(srccolor), GetBValue(srccolor) ); float ffogval; if( g_fogtype == 0.0f ){ //ffogval = ( g_fogend - g_proj_far ) / ( g_fogend - g_fogstart ); ffogval = ( g_fogend - m_fogdist ) / ( g_fogend - g_fogstart ); if( ffogval < 0.0f ) ffogval = 0.0f; if( ffogval > 1.0f ) ffogval = 1.0f; }else{ ffogval = 0.5f; } unsigned char ucfog; ucfog = (unsigned char)(ffogval * 255.0f); float deltau, deltav; deltau = ( enduv.u - startuv.u ) / (float)(BGUNUM - 1); deltav = ( enduv.v - startuv.v ) / (float)(BGVNUM - 1); int uno, vno; int tlvno = 0; for( vno = 0; vno < BGVNUM; vno++ ){ for( uno = 0; uno < BGUNUM; uno++ ){ m_tlv1[tlvno].tu = startuv.u + (float)uno * deltau; m_tlv1[tlvno].tv = startuv.v + (float)vno * deltav; // 一番奥 m_tlv1[tlvno].sz = zmax; m_tlv1[tlvno].rhw = 1.0f / zmax; m_tlv1[tlvno].color = curcolor; //m_tlv1[tlvno].specular = 0xFF000000; m_tlv1[tlvno].specular = ucfog << 24; ///////// m_tlv2[tlvno].tu1 = startuv.u + (float)uno * deltau; m_tlv2[tlvno].tv1 = startuv.v + (float)vno * deltav; m_tlv2[tlvno].tu2 = startuv.u + (float)uno * deltau; m_tlv2[tlvno].tv2 = startuv.v + (float)vno * deltav; // 一番奥 m_tlv2[tlvno].sz = zmax; m_tlv2[tlvno].rhw = 1.0f / zmax; m_tlv2[tlvno].color = curcolor; m_tlv2[tlvno].specular = ucfog << 24; //m_tlv2[tlvno].specular = 0xFF000000; tlvno++; } } int curindex = 0; for( vno = 0; vno < (BGVNUM - 1); vno++ ){ for( uno = 0; uno < (BGUNUM - 1); uno++ ){ m_Indices[curindex] = BGUNUM * vno + uno; m_Indices[curindex + 2] = BGUNUM * (vno + 1) + uno; m_Indices[curindex + 1] = BGUNUM * vno + uno + 1; curindex += 3; m_Indices[curindex] = BGUNUM * (vno + 1) + uno; m_Indices[curindex + 2] = BGUNUM * (vno + 1) + uno + 1; m_Indices[curindex + 1] = BGUNUM * vno + uno + 1; curindex += 3; } } //m_Indices[0] = 1; //m_Indices[1] = 3; //m_Indices[2] = 0; //m_Indices[3] = 2; ret = CheckMultiTexOk( pd3dDevice ); if( ret ){ multitexok = 0; DbgOut( "bgdisp2 : ini : CheckMultiTexOk : warning !!!\n" ); } ret = Create3DBuffers( pd3dDevice ); _ASSERT( !ret ); if( ret ){ DbgOut( "bgdisp2 : Create3DBuffers error !!!\n" ); } if( resetflag == 0 ){ ret = CreateTexture( pd3dDevice ); _ASSERT( !ret ); if( ret ){ DbgOut( "bgdisp2 : CreateTexture error !!!\n" ); } } ret = Copy2IndexBuffer(); _ASSERT( !ret ); if( ret ){ DbgOut( "bgdisp2 : Copy2IndexBuffer error !!!\n" ); } ret = Copy2VertexBuffer(); _ASSERT( !ret ); if( ret ){ DbgOut( "bgdisp2 : Copy2VertexBuffer error !!!\n" ); } /////////////// // pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR ); // pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR ); if( g_cop0 != D3DTOP_MODULATE ){ pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); g_cop0 = D3DTOP_MODULATE; } if( g_aop0 != D3DTOP_MODULATE ){ pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );//!!!! g_aop0 = D3DTOP_MODULATE; } pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); pd3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP ); pd3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP ); pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE ); pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE ); //pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE );//頂点色はソフトウェアで計算します。 pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE ); pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW ); //pd3dDevice->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_FLAT ); pd3dDevice->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_GOURAUD ); pd3dDevice->SetRenderState( D3DRS_WRAP0, 0 ); pd3dDevice->SetRenderState( D3DRS_DITHERENABLE, TRUE ); pd3dDevice->SetRenderState( D3DRS_SPECULARENABLE, TRUE ); pd3dDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE ); //pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0x40404040 ); pd3dDevice->SetRenderState( D3DRS_AMBIENT, D3DCOLOR_COLORVALUE( 0.40, 0.40, 0.40, 1.0 ) ); pd3dDevice->SetRenderState( D3DRS_NORMALIZENORMALS, FALSE ); pd3dDevice->SetRenderState( D3DRS_VERTEXBLEND, D3DVBF_DISABLE ); ////// //pd3dDevice->SetRenderState( D3DRENDERSTATE_ZENABLE, D3DZB_TRUE ); pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE ); m_minfilter = D3DTEXF_LINEAR; m_magfilter = D3DTEXF_LINEAR; }
static ssize_t write(struct file *file, const char *buf, size_t count, loff_t *ppos) { int i = 0; *ppos = 0; /* file position not used, always set to 0 */ /* DbgOut((KERN_ERR "tspdrv: write....\n")); */ /* ** Prevent unauthorized caller to write data. ** TouchSense service is the only valid caller. */ if (file->private_data != (void *)TSPDRV_MAGIC_NUMBER) { DbgOut((KERN_ERR "tspdrv: unauthorized write.\n")); return 0; } #ifdef CONFIG_TACTILE_ASSIST /* Check buffer size */ if ((count < SPI_HEADER_SIZE) || (count > SPI_BUFFER_SIZE)) { DbgOut((KERN_ERR "tspdrv: invalid write buffer size.\n")); return 0; } if (count == SPI_HEADER_SIZE) g_bOutputDataBufferEmpty = 1; else g_bOutputDataBufferEmpty = 0; #else if ((count <= SPI_HEADER_SIZE) || (count > SPI_BUFFER_SIZE)) { DbgOut((KERN_ERR "tspdrv: invalid write buffer size.\n")); return 0; } #endif /* Copy immediately the input buffer */ if (0 != copy_from_user(g_cwrite_buffer, buf, count)) { /* Failed to copy all the data, exit */ DbgOut((KERN_ERR "tspdrv: copy_from_user failed.\n")); return 0; } while (i < count) { int nindex_free_buffer; /* initialized below */ samples_buffer *pinput_buffer = (samples_buffer *)(&g_cwrite_buffer[i]); #ifdef CONFIG_TACTILE_ASSIST if ((i + SPI_HEADER_SIZE) > count) { #else if ((i + SPI_HEADER_SIZE) >= count) { #endif /* ** Index is about to go beyond the buffer size. ** (Should never happen). */ DbgOut((KERN_EMERG "tspdrv: invalid buffer index.\n")); return 0; } /* Check bit depth */ if (8 != pinput_buffer->nbit_depth) DbgOut((KERN_WARNING "tspdrv: invalid bit depth.Use default value(8).\n")); /* The above code not valid if SPI header size is not 3 */ #if (SPI_HEADER_SIZE != 3) #error "SPI_HEADER_SIZE expected to be 3" #endif /* Check buffer size */ if ((i + SPI_HEADER_SIZE + pinput_buffer->nbuffer_size) > count) { /* ** Index is about to go beyond the buffer size. ** (Should never happen). */ DbgOut((KERN_EMERG "tspdrv: invalid data size.\n")); return 0; } /* Check actuator index */ if (NUM_ACTUATORS <= pinput_buffer->nactuator_index) { DbgOut((KERN_ERR "tspdrv: invalid actuator index.\n")); i += (SPI_HEADER_SIZE + pinput_buffer->nbuffer_size); continue; } if (0 == g_samples_buffer[pinput_buffer->nactuator_index] .actuator_samples[0].nbuffer_size) { nindex_free_buffer = 0; } else if (0 == g_samples_buffer[pinput_buffer->nactuator_index] .actuator_samples[1].nbuffer_size) { nindex_free_buffer = 1; } else { /* No room to store new samples */ DbgOut((KERN_ERR "tspdrv: no room to store new samples.\n")); return 0; } /* Store the data in the free buffer of the given actuator */ memcpy( &(g_samples_buffer[pinput_buffer->nactuator_index] .actuator_samples[nindex_free_buffer]), &g_cwrite_buffer[i], (SPI_HEADER_SIZE + pinput_buffer->nbuffer_size)); /* If the no buffer is playing, prepare to play ** g_samples_buffer[pinput_buffer->nactuator_index]. ** actuator_samples[nindex_free_buffer] */ if (-1 == g_samples_buffer[pinput_buffer->nactuator_index] .nindex_playing_buffer) { g_samples_buffer[pinput_buffer->nactuator_index] .nindex_playing_buffer = nindex_free_buffer; g_samples_buffer[pinput_buffer->nactuator_index] .nindex_output_value = 0; } /* Increment buffer index */ i += (SPI_HEADER_SIZE + pinput_buffer->nbuffer_size); } #ifdef QA_TEST g_nforcelog[g_nforcelog_index++] = g_cSPIBuffer[0]; if (g_nforcelog_index >= FORCE_LOG_BUFFER_SIZE) { for (i = 0; i < FORCE_LOG_BUFFER_SIZE; i++) { printk(KERN_INFO "%d\t%d\n", g_ntime, g_nforcelog[i]); g_ntime += TIME_INCREMENT; } g_nforcelog_index = 0; } #endif /* Start the timer after receiving new output force */ g_bisplaying = true; VibeOSKernelLinuxStartTimer(); return count; } static long ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { #ifdef QA_TEST int i; #endif printk(KERN_DEBUG "tspdrv: %s %d\n", __func__, cmd); /* DbgOut(KERN_INFO "tspdrv: ioctl cmd[0x%x].\n", cmd); */ switch (cmd) { case TSPDRV_STOP_KERNEL_TIMER: /* ** As we send one sample ahead of time, we need to finish ** playing the last sample before stopping the timer. ** So we just set a flag here. */ if (true == g_bisplaying) g_bstoprequested = true; #ifdef VIBEOSKERNELPROCESSDATA /* Last data processing to disable amp and stop timer */ VibeOSKernelProcessData(NULL); #endif #ifdef QA_TEST if (g_nforcelog_index) { for (i = 0; i < g_nforcelog_index; i++) { printk(KERN_INFO "%d\t%d\n" , g_ntime, g_nforcelog[i]); g_ntime += TIME_INCREMENT; } } g_ntime = 0; g_nforcelog_index = 0; #endif break; case TSPDRV_MAGIC_NUMBER: #ifdef CONFIG_TACTILE_ASSIST case TSPDRV_SET_MAGIC_NUMBER: #endif filp->private_data = (void *)TSPDRV_MAGIC_NUMBER; break; case TSPDRV_ENABLE_AMP: wake_lock(&vib_wake_lock); vibe_set_pwm_freq(0); vibe_pwm_onoff(1); ImmVibeSPI_ForceOut_AmpEnable(arg); DbgRecorderReset((arg)); DbgRecord((arg, ";------- TSPDRV_ENABLE_AMP ---------\n")); break; case TSPDRV_DISABLE_AMP: /* ** Small fix for now to handle proper combination of ** TSPDRV_STOP_KERNEL_TIMER and TSPDRV_DISABLE_AMP together ** If a stop was requested, ignore the request as the amp ** will be disabled by the timer proc when it's ready */ #ifdef CONFIG_TACTILE_ASSIST g_bstoprequested = true; /* Last data processing to disable amp and stop timer */ VibeOSKernelProcessData(NULL); g_bisplaying = false; #else if (!g_bstoprequested) ImmVibeSPI_ForceOut_AmpDisable(arg); #endif wake_unlock(&vib_wake_lock); break; case TSPDRV_GET_NUM_ACTUATORS: return NUM_ACTUATORS; } return 0; }
DWORD CALLBACK ToasterClassInstaller( _In_ DI_FUNCTION InstallFunction, _In_ HDEVINFO DeviceInfoSet, _In_ PSP_DEVINFO_DATA DeviceInfoData OPTIONAL ) /*++ Routine Description: Responds to Class-installer messages . Arguments: InstallFunction [in] DeviceInfoSet [in] DeviceInfoData [in] Return Value: Returns: NO_ERROR, ERROR_DI_POSTPROCESSING_REQUIRED, or an error code. --*/ { switch (InstallFunction) { case DIF_INSTALLDEVICE: // // Sent twice: once before installing the device and once // after installing device, if you have returned // ERROR_DI_POSTPROCESSING_REQUIRED during the first pass. // DbgOut("DIF_INSTALLDEVICE"); break; case DIF_ADDPROPERTYPAGE_ADVANCED: // // Sent when you check the properties of the device in the // device manager. // DbgOut("DIF_ADDPROPERTYPAGE_ADVANCED"); return PropPageProvider(DeviceInfoSet, DeviceInfoData); case DIF_POWERMESSAGEWAKE: // // Sent when you check the power management tab // DbgOut("DIF_POWERMESSAGEWAKE"); break; case DIF_PROPERTYCHANGE: // // Sent when you change the property of the device using // SetupDiSetDeviceInstallParams. (Enable/Disable/Restart) // DbgOut("DIF_PROPERTYCHANGE"); break; case DIF_REMOVE: // // Sent when you uninstall the device. // DbgOut("DIF_REMOVE"); break; case DIF_NEWDEVICEWIZARD_FINISHINSTALL: // // Sent near the end of installation to allow // an installer to supply wizard page(s) to the user. // These wizard pages are different from the device manager // property sheet.There are popped only once during install. // DbgOut("DIF_NEWDEVICEWIZARD_FINISHINSTALL"); break; case DIF_SELECTDEVICE: DbgOut("DIF_SELECTDEVICE"); break; case DIF_DESTROYPRIVATEDATA: // // Sent when Setup destroys a device information set // or an SP_DEVINFO_DATA element, or when Setup discards // its list of co-installers and class installer for a device // DbgOut("DIF_DESTROYPRIVATEDATA"); break; case DIF_INSTALLDEVICEFILES: DbgOut("DIF_INSTALLDEVICEFILES"); break; case DIF_ALLOW_INSTALL: // // Sent to confirm whether the installer wants to allow // the installation of device. // DbgOut("DIF_ALLOW_INSTALL"); break; case DIF_SELECTBESTCOMPATDRV: DbgOut("DIF_SELECTBESTCOMPATDRV"); break; case DIF_INSTALLINTERFACES: DbgOut("DIF_INSTALLINTERFACES"); break; case DIF_REGISTER_COINSTALLERS: DbgOut("DIF_REGISTER_COINSTALLERS"); break; default: DbgOut("DIF_???"); break; } return ERROR_DI_DO_DEFAULT; }
static int ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) #endif { switch (cmd) { case TSPDRV_SET_MAGIC_NUMBER: file->private_data = (void*)TSPDRV_MAGIC_NUMBER; break; case TSPDRV_ENABLE_AMP: ImmVibeSPI_ForceOut_AmpEnable(arg); #ifdef VIBE_RUNTIME_RECORD if (atomic_read(&g_bRuntimeRecord)) { DbgRecord((arg,";------- TSPDRV_ENABLE_AMP ---------\n")); } #else DbgRecorderReset((arg)); DbgRecord((arg,";------- TSPDRV_ENABLE_AMP ---------\n")); #endif break; case TSPDRV_DISABLE_AMP: ImmVibeSPI_ForceOut_AmpDisable(arg); #ifdef VIBE_RUNTIME_RECORD if (atomic_read(&g_bRuntimeRecord)) { DbgRecord((arg,";------- TSPDRV_DISABLE_AMP ---------\n")); } #endif break; case TSPDRV_GET_NUM_ACTUATORS: return NUM_ACTUATORS; case TSPDRV_SET_DBG_LEVEL: { long nDbgLevel; if (0 != copy_from_user((void *)&nDbgLevel, (const void __user *)arg, sizeof(long))) { /* Error copying the data */ DbgOut((DBL_ERROR, "copy_from_user failed to copy debug level data.\n")); return -1; } if (DBL_TEMP <= nDbgLevel && nDbgLevel <= DBL_OVERKILL) atomic_set(&g_nDebugLevel, nDbgLevel); else DbgOut((DBL_ERROR, "Invalid debug level requested, ignored.")); break; } case TSPDRV_GET_DBG_LEVEL: return atomic_read(&g_nDebugLevel); #ifdef VIBE_RUNTIME_RECORD case TSPDRV_SET_RUNTIME_RECORD_FLAG: { long nRecordFlag; if (0 != copy_from_user((void *)&nRecordFlag, (const void __user *)arg, sizeof(long))) { /* Error copying the data */ DbgOut((DBL_ERROR, "copy_from_user failed to copy runtime record flag.\n")); return -1; } atomic_set(&g_bRuntimeRecord, nRecordFlag); if (nRecordFlag) { int i; for (i = 0; i < NUM_ACTUATORS; i++) { DbgRecorderReset((i)); } } break; } case TSPDRV_GET_RUNTIME_RECORD_FLAG: return atomic_read(&g_bRuntimeRecord); case TSPDRV_SET_RUNTIME_RECORD_BUF_SIZE: { long nRecorderBufSize; if (0 != copy_from_user((void *)&nRecorderBufSize, (const void __user *)arg, sizeof(long))) { /* Error copying the data */ DbgOut((DBL_ERROR, "copy_from_user failed to copy recorder buffer size.\n")); return -1; } if (0 == DbgSetRecordBufferSize(nRecorderBufSize)) { DbgOut((DBL_ERROR, "DbgSetRecordBufferSize failed.\n")); return -1; } break; } case TSPDRV_GET_RUNTIME_RECORD_BUF_SIZE: return DbgGetRecordBufferSize(); #endif case TSPDRV_SET_DEVICE_PARAMETER: { device_parameter deviceParam; if (0 != copy_from_user((void *)&deviceParam, (const void __user *)arg, sizeof(deviceParam))) { /* Error copying the data */ DbgOut((DBL_ERROR, "tspdrv: copy_from_user failed to copy kernel parameter data.\n")); return -1; } switch (deviceParam.nDeviceParamID) { case VIBE_KP_CFG_UPDATE_RATE_MS: /* Update the timer period */ g_nTimerPeriodMs = deviceParam.nDeviceParamValue; #ifdef CONFIG_HIGH_RES_TIMERS /* For devices using high resolution timer we need to update the ktime period value */ g_ktTimerPeriod = ktime_set(0, g_nTimerPeriodMs * 1000000); #endif break; case VIBE_KP_CFG_FREQUENCY_PARAM1: case VIBE_KP_CFG_FREQUENCY_PARAM2: case VIBE_KP_CFG_FREQUENCY_PARAM3: case VIBE_KP_CFG_FREQUENCY_PARAM4: case VIBE_KP_CFG_FREQUENCY_PARAM5: case VIBE_KP_CFG_FREQUENCY_PARAM6: if (0 > ImmVibeSPI_ForceOut_SetFrequency(deviceParam.nDeviceIndex, deviceParam.nDeviceParamID, deviceParam.nDeviceParamValue)) { DbgOut((DBL_ERROR, "tspdrv: cannot set device frequency parameter.\n")); return -1; } break; } } } return 0; }
static void platform_release(struct device *dev) { DbgOut((DBL_ERROR, "tspdrv: platform_release.\n")); }
int init_module(void) { int nRet, i; /* initialized below */ #ifdef IMPLEMENT_AS_CHAR_DRIVER g_nMajor = register_chrdev(0, MODULE_NAME, &fops); if (g_nMajor < 0) { DbgOut((KERN_ERR "tspdrv: can't get major number.\n")); return g_nMajor; } #else nRet = misc_register(&miscdev); if (nRet) { DbgOut((KERN_ERR "tspdrv: misc_register failed.\n")); return nRet; } #endif nRet = platform_device_register(&platdev); if (nRet) DbgOut((KERN_ERR "tspdrv: platform_device_register failed.\n")); nRet = platform_driver_register(&platdrv); if (nRet) DbgOut((KERN_ERR "tspdrv: platform_driver_register failed.\n")); nRet = platform_driver_register(&max8997_hapticmotor_driver); if (nRet) DbgOut((KERN_ERR "tspdrv: platform_driver_register failed (hapticmotor).\n")); DbgRecorderInit(()); vibetonz_clk_on(&platdev.dev); ImmVibeSPI_ForceOut_Initialize(); VibeOSKernelLinuxInitTimer(); /* Get and concatenate device name and initialize data buffer */ g_cchDeviceName = 0; for (i = 0; i < NUM_ACTUATORS; i++) { char *szName = g_szDeviceName + g_cchDeviceName; ImmVibeSPI_Device_GetName(i, szName, VIBE_MAX_DEVICE_NAME_LENGTH); /* Append version information and get buffer length */ strcat(szName, VERSION_STR); g_cchDeviceName += strlen(szName); g_SamplesBuffer[i].nIndexPlayingBuffer = -1; /* Not playing */ g_SamplesBuffer[i].actuatorSamples[0].nBufferSize = 0; g_SamplesBuffer[i].actuatorSamples[1].nBufferSize = 0; } wake_lock_init(&vib_wake_lock, WAKE_LOCK_SUSPEND, "vib_present"); if (device_create_file(&platdev.dev, &dev_attr_vibrator_level_max) < 0) { printk(KERN_ERR "Failed to create device file(%s)!\n", dev_attr_vibrator_level_max.attr.name); } if (device_create_file(&platdev.dev, &dev_attr_vibrator_level) < 0) { printk(KERN_ERR "Failed to create device file(%s)!\n", dev_attr_vibrator_level.attr.name); } vibetonz_start(); return 0; }
static ssize_t write( struct file *file, const char *buf, size_t count, loff_t *ppos ) { int i = 0; *ppos = 0; /* file position not used, always set to 0 */ /* ** Prevent unauthorized caller to write data. ** TouchSense service is the only valid caller. */ if ( file->private_data != (void*)TSPDRV_MAGIC_NUMBER ) { DbgOut( ( KERN_ERR "tspdrv: unauthorized write.\n" ) ); return 0; } /* Copy immediately the input buffer */ if ( 0 != copy_from_user( g_cWriteBuffer, buf, count ) ) { /* Failed to copy all the data, exit */ DbgOut( ( KERN_ERR "tspdrv: copy_from_user failed.\n" ) ); return 0; } /* Check buffer size */ if ( ( count <= SPI_HEADER_SIZE ) || ( count > SPI_BUFFER_SIZE ) ) { DbgOut( ( KERN_ERR "tspdrv: invalid write buffer size.\n" ) ); return 0; } while ( i < count ) { int nIndexFreeBuffer; /* initialized below */ samples_buffer* pInputBuffer = (samples_buffer*)(&g_cWriteBuffer[i]); if ( ( i + SPI_HEADER_SIZE ) >= count ) { /* ** Index is about to go beyond the buffer size. ** (Should never happen). */ DbgOut( ( KERN_EMERG "tspdrv: invalid buffer index.\n" ) ); } /* Check bit depth */ if ( 8 != pInputBuffer->nBitDepth ) { DbgOut( ( KERN_WARNING "tspdrv: invalid bit depth. Use default value (8).\n" ) ); } /* The above code not valid if SPI header size is not 3 */ #if ( SPI_HEADER_SIZE != 3 ) #error "SPI_HEADER_SIZE expected to be 3" #endif /* Check buffer size */ if ( ( i + SPI_HEADER_SIZE + pInputBuffer->nBufferSize ) > count ) { /* ** Index is about to go beyond the buffer size. ** (Should never happen). */ DbgOut( ( KERN_EMERG "tspdrv: invalid data size.\n" ) ); } /* Check actuator index */ if ( NUM_ACTUATORS <= pInputBuffer->nActuatorIndex ) { DbgOut( ( KERN_ERR "tspdrv: invalid actuator index.\n" ) ); i += ( SPI_HEADER_SIZE + pInputBuffer->nBufferSize ); continue; } if ( 0 == g_SamplesBuffer[pInputBuffer->nActuatorIndex].actuatorSamples[0].nBufferSize ) { nIndexFreeBuffer = 0; } else if ( 0 == g_SamplesBuffer[pInputBuffer->nActuatorIndex].actuatorSamples[1].nBufferSize ) { nIndexFreeBuffer = 1; } else { /* No room to store new samples */ DbgOut( ( KERN_ERR "tspdrv: no room to store new samples.\n" ) ); return 0; } /* Store the data in the free buffer of the given actuator */ memcpy( &(g_SamplesBuffer[pInputBuffer->nActuatorIndex].actuatorSamples[nIndexFreeBuffer]), &g_cWriteBuffer[i], (SPI_HEADER_SIZE + pInputBuffer->nBufferSize) ); /* If the no buffer is playing, prepare to play g_SamplesBuffer[pInputBuffer->nActuatorIndex].actuatorSamples[nIndexFreeBuffer] */ if ( -1 == g_SamplesBuffer[pInputBuffer->nActuatorIndex].nIndexPlayingBuffer ) { g_SamplesBuffer[pInputBuffer->nActuatorIndex].nIndexPlayingBuffer = nIndexFreeBuffer; g_SamplesBuffer[pInputBuffer->nActuatorIndex].nIndexOutputValue = 0; } /* Increment buffer index */ i += ( SPI_HEADER_SIZE + pInputBuffer->nBufferSize ); } // end of while #ifdef QA_TEST g_nForceLog[g_nForceLogIndex++] = g_cSPIBuffer[0]; if ( g_nForceLogIndex >= FORCE_LOG_BUFFER_SIZE ) { for ( i=0; i<FORCE_LOG_BUFFER_SIZE; i++ ) { printk( "<6>%d\t%d\n", g_nTime, g_nForceLog[i] ); g_nTime += TIME_INCREMENT; } g_nForceLogIndex = 0; } #endif /* Start the timer after receiving new output force */ g_bIsPlaying = true; VibeOSKernelLinuxStartTimer( ); return count; }
/* ** Called to enable amp (enable output force0) */ IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_AmpEnable(VibeUInt8 nActuatorIndex) { int cnt = 0; unsigned char I2C_data[1]; int ret = VIBE_S_SUCCESS; int fd = 0; mm_segment_t oldfs = get_fs(); set_fs(KERNEL_DS); fd = sys_open("/sdcard/vib.txt", O_RDONLY , 0755); if (!g_bAmpEnabled) { DbgOut((KERN_DEBUG "ImmVibeSPI_ForceOut_AmpEnable.\n")); g_bAmpEnabled = true; PWM_CLK_ENABLE; #ifdef ISA1200_HEN_ENABLE SYS_API_HEN_HIGH; #endif if(fd >= 0) //ELT Test Mode { printk("[ImmVibeSPI_ForceOut_AmpEnable] Case : ELT Test Vibration\n"); if(status == 0){ printk("[ImmVibeSPI_ForceOut_AmpEnable] ELT : Register Setting \n"); I2C_data[0] = LDO_VOLTAGE_30V; // LDO Voltage : 3.0V do { ret = SYS_API__I2C__Write(SCTRL, I2C_data[0]); cnt++; }while(VIBE_S_SUCCESS != ret && cnt < RETRY_CNT); if( VIBE_S_SUCCESS != ret) DEBUG_MSG("[ImmVibeSPI_ForceOut_Initialize] I2C_Write Error, Slave Address = [%d], ret = [%d]\n", I2C_data[0], ret); I2C_data[0] = 0x93; //224Hz do{ ret = SYS_API__I2C__Write(HCTRL4, I2C_data[0]); cnt++; }while(VIBE_S_SUCCESS != ret && cnt < RETRY_CNT); if( VIBE_S_SUCCESS != ret) DEBUG_MSG("[ImmVibeSPI_ForceOut_Initialize] I2C_Write Error, Slave Address = [%d], ret = [%d]\n", I2C_data[0], ret); I2C_data[0] = tspdrv_i2c_read_byte_data(SCTRL); printk("[ImmVibeSPI_ForceOut_AmpEnable] ELT HCTRL0 written data : 0x%x\n", I2C_data[0]); I2C_data[0] = tspdrv_i2c_read_byte_data(HCTRL4); printk("[ImmVibeSPI_ForceOut_AmpEnable] ELT HCTRL1 written data : 0x%x\n", I2C_data[0]); status = 1; } else{ //Normal Mode printk("[ImmVibeSPI_ForceOut_AmpEnable] ELT : just vibrate \n"); } } else{ printk("[ImmVibeSPI_ForceOut_AmpEnable] Case : Normal Vibration\n"); if(status == 1){ printk("[ImmVibeSPI_ForceOut_AmpEnable] Normal : Register Setting \n"); I2C_data[0] = g_nLDO_Voltage; // LDO Voltage : 2.7V do { ret = SYS_API__I2C__Write(SCTRL, I2C_data[0]); cnt++; }while(VIBE_S_SUCCESS != ret && cnt < RETRY_CNT); if( VIBE_S_SUCCESS != ret) DEBUG_MSG("[ImmVibeSPI_ForceOut_Initialize] I2C_Write Error, Slave Address = [%d], ret = [%d]\n", I2C_data[0], ret); I2C_data[0] = 0x94; //230Hz do{ ret = SYS_API__I2C__Write(HCTRL4, I2C_data[0]); cnt++; }while(VIBE_S_SUCCESS != ret && cnt < RETRY_CNT); if( VIBE_S_SUCCESS != ret) DEBUG_MSG("[ImmVibeSPI_ForceOut_Initialize] I2C_Write Error, Slave Address = [%d], ret = [%d]\n", I2C_data[0], ret); I2C_data[0] = tspdrv_i2c_read_byte_data(SCTRL); printk("[ImmVibeSPI_ForceOut_AmpEnable] Normal HCTRL0 written data : 0x%x\n", I2C_data[0]); I2C_data[0] = tspdrv_i2c_read_byte_data(HCTRL4); printk("[ImmVibeSPI_ForceOut_AmpEnable] Normal HCTRL1 written data : 0x%x\n", I2C_data[0]); status =0; } else{ printk("[ImmVibeSPI_ForceOut_AmpEnable] Normal : just vibrate \n"); } } I2C_data[0] = 0x88; // Haptic Drive Enable + PWM Input mode do { ret = SYS_API__I2C__Write(HCTRL0, I2C_data[0]); cnt++; }while(VIBE_S_SUCCESS != ret && cnt < RETRY_CNT); if( VIBE_S_SUCCESS != ret) DEBUG_MSG("[ImmVibeSPI_ForceOut_AmpEnable] I2C_Write Error, Slave Address = [%d], ret = [%d]\n", I2C_data[0], ret); #if 0 I2C_data[0] = tspdrv_i2c_read_byte_data(HCTRL0); printk("HCTRL0 written data : 0x%x\n", I2C_data[0]); I2C_data[0] = tspdrv_i2c_read_byte_data(HCTRL1); printk("HCTRL1 written data : 0x%x\n", I2C_data[0]); I2C_data[0] = tspdrv_i2c_read_byte_data(HCTRL2); printk("HCTRL2 written data : 0x%x\n", I2C_data[0]); I2C_data[0] = tspdrv_i2c_read_byte_data(HCTRL3); printk("HCTRL3 written data : 0x%x\n", I2C_data[0]); I2C_data[0] = tspdrv_i2c_read_byte_data(HCTRL4); printk("HCTRL4 written data : 0x%x\n", I2C_data[0]); #endif } sys_close(fd); set_fs(oldfs); return VIBE_S_SUCCESS; }
/* ** Called at initialization time to set PWM frequencies, disable amp, etc... */ IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_Initialize(void) { int cnt = 0; unsigned char I2C_data[1]; int ret = VIBE_S_SUCCESS; DbgOut((KERN_DEBUG "ImmVibeSPI_ForceOut_Initialize.\n")); SYS_API_VDDP_ON; SYS_API_LEN_HIGH; SLEEP(20 /*ms*/); I2C_data[0] = g_nLDO_Voltage; // LDO Voltage do { ret = SYS_API__I2C__Write(SCTRL, I2C_data[0]); cnt++; }while(VIBE_S_SUCCESS != ret && cnt < RETRY_CNT); if( VIBE_S_SUCCESS != ret) DEBUG_MSG("[ImmVibeSPI_ForceOut_Initialize] I2C_Write Error, Slave Address = [%d], ret = [%d]\n", I2C_data[0], ret); I2C_data[0] = 0x08; // Haptic Drive Disable + PWM Input mode do { ret = SYS_API__I2C__Write(HCTRL0, I2C_data[0]); cnt++; }while(VIBE_S_SUCCESS != ret && cnt < RETRY_CNT); if( VIBE_S_SUCCESS != ret) DEBUG_MSG("[ImmVibeSPI_ForceOut_Initialize] I2C_Write Error, Slave Address = [%d], ret = [%d]\n", I2C_data[0], ret); I2C_data[0] = 0x40; // EXT clock + DAC inversion + LRA do { ret = SYS_API__I2C__Write(HCTRL1, I2C_data[0]); cnt++; }while(VIBE_S_SUCCESS != ret && cnt < RETRY_CNT); if( VIBE_S_SUCCESS != ret) DEBUG_MSG("[ImmVibeSPI_ForceOut_Initialize] I2C_Write Error, Slave Address = [%d], ret = [%d]\n", I2C_data[0], ret); I2C_data[0] = 0x00; // Disable Software Reset do { ret = SYS_API__I2C__Write(HCTRL2, I2C_data[0]); cnt++; }while(VIBE_S_SUCCESS != ret && cnt < RETRY_CNT); if( VIBE_S_SUCCESS != ret) DEBUG_MSG("[ImmVibeSPI_ForceOut_Initialize] I2C_Write Error, Slave Address = [%d], ret = [%d]\n", I2C_data[0], ret); I2C_data[0] = 0x13; // Disable Software Reset do { ret = SYS_API__I2C__Write(HCTRL3, I2C_data[0]); cnt++; }while(VIBE_S_SUCCESS != ret && cnt < RETRY_CNT); if( VIBE_S_SUCCESS != ret) DEBUG_MSG("[ImmVibeSPI_ForceOut_Initialize] I2C_Write Error, Slave Address = [%d], ret = [%d]\n", I2C_data[0], ret); I2C_data[0] = 0x93; //20.3KHz -> 229.xHz do { ret = SYS_API__I2C__Write(HCTRL4, I2C_data[0]); cnt++; }while(VIBE_S_SUCCESS != ret && cnt < RETRY_CNT); if( VIBE_S_SUCCESS != ret) DEBUG_MSG("[ImmVibeSPI_ForceOut_Initialize] I2C_Write Error, Slave Address = [%d], ret = [%d]\n", I2C_data[0], ret); I2C_data[0] = 0x00; do { ret = SYS_API__I2C__Write(HCTRL5, I2C_data[0]); cnt++; }while(VIBE_S_SUCCESS != ret && cnt < RETRY_CNT); if( VIBE_S_SUCCESS != ret) DEBUG_MSG("[ImmVibeSPI_ForceOut_Initialize] I2C_Write Error, Slave Address = [%d], ret = [%d]\n", I2C_data[0], ret); I2C_data[0] = 0x00; do { ret = SYS_API__I2C__Write(HCTRL6, I2C_data[0]); cnt++; }while(VIBE_S_SUCCESS != ret && cnt < RETRY_CNT); if( VIBE_S_SUCCESS != ret) DEBUG_MSG("[ImmVibeSPI_ForceOut_Initialize] I2C_Write Error, Slave Address = [%d], ret = [%d]\n", I2C_data[0], ret); return VIBE_S_SUCCESS; }
static ssize_t write(struct file *file, const char *buf, size_t count, loff_t *ppos) { char cBuffer[1]; mutex_lock(&(timer_state.lock)); if(timer_state.state==TIMER_DISABLED) { GPtimer_enable(); timer_state.state = TIMER_ENABLED; } mutex_unlock(&(timer_state.lock)); *ppos = 0; /* file position not used, always set to 0 */ /* ** Prevent unauthorized caller to write data. ** VibeTonz service is the only valid caller. */ if (file->private_data != (void*)VTMDRV_MAGIC_NUMBER) { DbgOut((KERN_ERR "vtmdrv: unauthorized write.\n")); return 0; } /* Check buffer size */ if (count != 1) { DbgOut((KERN_ERR "vtmdrv: invalid write buffer size.\n")); return 0; } if (0 != copy_from_user(cBuffer, buf, count)) { /* Failed to copy all the data, exit */ DbgOut((KERN_ERR "vtmdrv: copy_from_user failed.\n")); return 0; } g_bIsPlaying = true; ImmVibeSPI_ForceOut_Set(cBuffer[0]); #ifdef QA_TEST g_nForceLog[g_nForceLogIndex++] = cBuffer[0]; if (g_nForceLogIndex >= FORCE_LOG_BUFFER_SIZE) { int i; for (i=0; i<FORCE_LOG_BUFFER_SIZE; i++) { printk("<6>%d\t%d\n", g_nTime, g_nForceLog[i]); g_nTime += TIME_INCREMENT; } g_nForceLogIndex = 0; } #endif #if 1 /* Start the timer after receiving new output force */ VibeOSKernelLinuxStartTimer(); #endif return count; }
/* ** Called by the real-time loop to set PWM duty cycle */ IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_SetSamples(VibeUInt8 nActuatorIndex, VibeUInt16 nOutputSignalBitDepth, VibeUInt16 nBufferSizeInBytes, VibeInt8 * pForceOutputBuffer) { #if 0 VibeInt8 nForce; switch (nOutputSignalBitDepth) { case 8: /* pForceOutputBuffer is expected to contain 1 byte */ if (nBufferSizeInBytes != 1) { DbgOut((KERN_ERR "[ImmVibeSPI] ImmVibeSPI_ForceOut_SetSamples nBufferSizeInBytes = %d\n", nBufferSizeInBytes)); return VIBE_E_FAIL; } nForce = pForceOutputBuffer[0]; break; case 16: /* pForceOutputBuffer is expected to contain 2 byte */ if (nBufferSizeInBytes != 2) return VIBE_E_FAIL; /* Map 16-bit value to 8-bit */ nForce = ((VibeInt16 *)pForceOutputBuffer)[0] >> 8; break; default: /* Unexpected bit depth */ return VIBE_E_FAIL; } if (nForce == 0) /* Set 50% duty cycle or disable amp */ else /* Map force from [-127, 127] to [0, PWM_DUTY_MAX] */ #endif VibeInt8 nForce; switch (nOutputSignalBitDepth) { case 8: /* pForceOutputBuffer is expected to contain 1 byte */ if (nBufferSizeInBytes != 1) { DbgOut((KERN_ERR "[ImmVibeSPI] ImmVibeSPI_ForceOut_SetSamples nBufferSizeInBytes = %d\n", nBufferSizeInBytes)); return VIBE_E_FAIL; } nForce = pForceOutputBuffer[0]; break; case 16: /* pForceOutputBuffer is expected to contain 2 byte */ if (nBufferSizeInBytes != 2) return VIBE_E_FAIL; /* Map 16-bit value to 8-bit */ nForce = ((VibeInt16 *)pForceOutputBuffer)[0] >> 8; break; default: /* Unexpected bit depth */ return VIBE_E_FAIL; } if (nForce == 0) { /* Set 50% duty cycle or disable amp */ ImmVibeSPI_ForceOut_AmpDisable(0); } else { /* Map force from [-127, 127] to [0, PWM_DUTY_MAX] */ ImmVibeSPI_ForceOut_AmpEnable(0); #if !defined(CONFIG_MACH_P4NOTE) vibtonz_pwm(nForce); #endif } return VIBE_S_SUCCESS; }
static int open(struct inode *inode, struct file *file) { DbgOut((KERN_INFO "vtmdrv: open.\n")); if (!try_module_get(THIS_MODULE)) return -ENODEV; return 0; }
Codec_Errors H263VideoEncoder::Open(MediaFormat* encFormat, CodecData* encData){ Codec_Errors retval = CODEC_SUCCEEDED; av_log_set_callback(&avlog_cb); try { sprintf(dbg_buffer, "Opening H263VideoEncoder\n"); DbgOut(dbg_buffer); avcodec_register_all(); //initialize codecs. CurrentFormat = encFormat; //store format settings. CurrentData = encData; VideoMediaFormat* vf = (VideoMediaFormat*)encFormat; //find the H.263 encoder. FFEncoder = avcodec_find_encoder(CODEC_ID_H263P); if(!FFEncoder) //if I didn't find it, return not supported. retval = CODEC_NOT_SUPPORTED; else{ sprintf(dbg_buffer, "\tFound codec\n"); DbgOut(dbg_buffer); //if we found the encoder, then instantiate the context and set config. FFEncoderContext = avcodec_alloc_context3(FFEncoder); FFEncoderContext->codec_type = AVMEDIA_TYPE_VIDEO; FFEncoderContext->bit_rate = ((double)encData->BitRate/8) / (double)vf->FPS; sprintf(dbg_buffer, "\tBit Rate = %d\n", FFEncoderContext->bit_rate); DbgOut(dbg_buffer); FFEncoderContext->width = vf->Width; FFEncoderContext->height = vf->Height; // FFEncoderContext->rc_max_rate = FFEncoderContext->bit_rate; // FFEncoderContext->rc_min_rate = FFEncoderContext->bit_rate; // FFEncoderContext->rc_buffer_size = FFEncoderContext->bit_rate * vf->FPS; AVRational fps; fps.num = vf->FPS; fps.den = 1; sprintf(dbg_buffer, "\tFrame Rate = %d\n", vf->FPS); DbgOut(dbg_buffer); FFEncoderContext->time_base = fps; FFEncoderContext->bit_rate_tolerance = FFEncoderContext->bit_rate*av_q2d(FFEncoderContext->time_base); FFEncoderContext->gop_size = encData->KeyFrameSpace; sprintf(dbg_buffer, "\tKFS = %d\n", FFEncoderContext->gop_size); DbgOut(dbg_buffer); FFEncoderContext->max_b_frames = 0; FFEncoderContext->pix_fmt = PIX_FMT_YUV420P; TempFrame = alloc_picture(PIX_FMT_YUV420P, vf->Width, vf->Height); sprintf(dbg_buffer, "\tWidth= %d, Height = %d, Format = %d\n", vf->Width, vf->Height, vf->PixelFormat); DbgOut(dbg_buffer); //if the input frame's format is going to be different from our format, then we need to scale. PixelFormat fmt = (PixelFormat)VideoMediaFormat::GetFFPixel(vf->PixelFormat); if(fmt != PIX_FMT_YUV420P) { sprintf(dbg_buffer, "\tInitializing Scaler\n"); DbgOut(dbg_buffer); //instantiate a scaler. ScaleContext = sws_getContext(vf->Width, vf->Height, fmt, vf->Width, vf->Height, PIX_FMT_YUV420P, SWS_BICUBIC, NULL, NULL, NULL); } //open the codec. int err = avcodec_open2(FFEncoderContext, FFEncoder,NULL); sprintf(dbg_buffer, "\tCodec Open returned %d\n", err); DbgOut(dbg_buffer); if(err < 0){ //if we failed to open, return error. retval = CODEC_FAILED_TO_OPEN; } } } catch(...) { retval = CODEC_UNEXPECTED; } sprintf(dbg_buffer, "Finished opening H263VideoEncoder\n"); DbgOut(dbg_buffer); return retval; }
int CBgDisp2::Render( LPDIRECT3DDEVICE9 pd3dDevice ) { // pd3dDevice->SetTexture( 0, NULL ); // g_curtex0 = NULL; // pd3dDevice->SetTexture( 1, NULL ); // g_curtex1 = NULL; //////// /*** pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); g_cop0 = D3DTOP_MODULATE; pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );//!!!! g_aop0 = D3DTOP_MODULATE; pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); pd3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP ); pd3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP ); pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE ); pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE ); //pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE );//頂点色はソフトウェアで計算します。 pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE ); pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW ); //pd3dDevice->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_FLAT ); pd3dDevice->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_GOURAUD ); pd3dDevice->SetRenderState( D3DRS_WRAP0, 0 ); pd3dDevice->SetRenderState( D3DRS_DITHERENABLE, TRUE ); pd3dDevice->SetRenderState( D3DRS_SPECULARENABLE, TRUE ); pd3dDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE ); //pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0x40404040 ); pd3dDevice->SetRenderState( D3DRS_AMBIENT, D3DCOLOR_COLORVALUE( 0.40, 0.40, 0.40, 1.0 ) ); pd3dDevice->SetRenderState( D3DRS_NORMALIZENORMALS, FALSE ); pd3dDevice->SetRenderState( D3DRS_VERTEXBLEND, D3DVBF_DISABLE ); //pd3dDevice->SetRenderState( D3DRENDERSTATE_ZENABLE, D3DZB_TRUE ); pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE ); ***/ /////// HRESULT hres; int ret = 0; hres = pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE ); if( hres != D3D_OK ){ DbgOut( "bgdisp2 : Render : SetRenderState 0 error !!!\n" ); } //pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP ); //pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP ); hres = pd3dDevice->SetRenderState( D3DRS_WRAP0, 0 ); g_renderstate[ D3DRS_WRAP0 ] = 0; if( hres != D3D_OK ){ DbgOut( "bgdisp2 : Render : SetRenderState 1 error !!!\n" ); } if( multitexok != 0 ){ hres = pd3dDevice->SetRenderState( D3DRS_WRAP1, 0 ); g_renderstate[ D3DRS_WRAP1 ] = 0; if( hres != D3D_OK ){ DbgOut( "bgdisp2 : Render : SetRenderState 2 error !!!\n" ); } } pd3dDevice->SetRenderState( D3DRS_FOGENABLE, g_fogenable ); pd3dDevice->SetRenderState( D3DRS_FOGCOLOR, g_fogcolor ); pd3dDevice->SetRenderState( D3DRS_FOGVERTEXMODE, D3DFOG_LINEAR ); pd3dDevice->SetRenderState( D3DRS_FOGTABLEMODE, D3DFOG_NONE ); pd3dDevice->SetRenderState( D3DRS_FOGSTART, *((DWORD*)(&g_fogstart)) ); pd3dDevice->SetRenderState( D3DRS_FOGEND, *((DWORD*)(&g_fogend)) ); LPDIRECT3DTEXTURE9 tex0 = g_texbnk->GetTexData( texname, transparent1 ); LPDIRECT3DTEXTURE9 tex1 = g_texbnk->GetTexData( texname2, transparent2 ); // if( g_curtex0 != tex0 ){ pd3dDevice->SetTexture( 0, tex0 ); g_curtex0 = tex0; // } //DbgOut( "bgdisp2 : Render : %s, %x : %s, %x\r\n", texname, tex0, texname2, tex1 ); if( tex1 && (multitexok != 0) ){ if( g_cop0 != D3DTOP_MODULATE ){ pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); g_cop0 = D3DTOP_MODULATE; } if( g_aop0 != D3DTOP_MODULATE ){ pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); g_aop0 = D3DTOP_MODULATE; } if( g_cop1 != D3DTOP_MODULATE ){ pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_MODULATE ); g_cop1 = D3DTOP_MODULATE; } if( g_aop1 != D3DTOP_MODULATE ){ pd3dDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_MODULATE );//!!!! g_aop1 = D3DTOP_MODULATE; } pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE ); g_renderstate[ D3DRS_SRCBLEND ] = D3DBLEND_ONE; pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE ); g_renderstate[ D3DRS_DESTBLEND ] = D3DBLEND_ONE; // if( g_curtex1 != tex1 ){ pd3dDevice->SetTexture( 1, tex1 ); g_curtex1 = tex1; // } }else{ if( g_cop0 != D3DTOP_MODULATE ){ pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); g_cop0 = D3DTOP_MODULATE; } if( g_cop1 != D3DTOP_DISABLE ){ pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE ); g_cop1 = D3DTOP_DISABLE; } if( g_aop0 != D3DTOP_SELECTARG1 ){ pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); g_aop0 = D3DTOP_SELECTARG1; } if( g_aop1 = D3DTOP_DISABLE ){ pd3dDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );//!!!! g_aop1 = D3DTOP_DISABLE; } // if( g_curtex1 != NULL ){ pd3dDevice->SetTexture( 1, NULL ); g_curtex1 = NULL; // } } //pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 ); //pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_SELECTARG1 ); //pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_ADD ); //pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_ADDSIGNED ); //pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_SUBTRACT ); //pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_PREMODULATE ); HRESULT hr1, hr2; DWORD curfilter; curfilter = m_minfilter; if( g_minfilter != curfilter ){ hr1 = pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, curfilter ); if( hr1 != D3D_OK ){ DbgOut( "sh : SetRenderState : minfilter 0 error !!!\n" ); } hr2 = pd3dDevice->SetSamplerState( 1, D3DSAMP_MINFILTER, curfilter ); if( hr2 != D3D_OK ){ DbgOut( "sh : SetRenderState : minfilter 1 error !!!\n" ); } g_minfilter = curfilter; } curfilter = m_magfilter; if( g_magfilter != curfilter ){ hr1 = pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, curfilter ); if( hr1 != D3D_OK ){ DbgOut( "sh : SetRenderState : magfilter 0 error !!!\n" ); } hr2 = pd3dDevice->SetSamplerState( 1, D3DSAMP_MAGFILTER, curfilter ); if( hr2 != D3D_OK ){ DbgOut( "sh : SetRenderState : magfilter 1 error !!!\n" ); } g_magfilter = curfilter; } if( multitexok == 0 ){ hres = pd3dDevice->SetVertexShader( NULL ); pd3dDevice->SetFVF( D3DFVF_TLVERTEX ); if( hres != D3D_OK ){ DbgOut( "bgdisp2 : Render : SetVertexShader error !!!\n" ); } hres = pd3dDevice->SetStreamSource( 0, m_VB, 0, sizeof(D3DTLVERTEX) ); if( hres != D3D_OK ){ DbgOut( "bgdisp2 : Render : SetStreamSource error !!!\n" ); } }else{ hres = pd3dDevice->SetVertexShader( NULL ); pd3dDevice->SetFVF( D3DFVF_TLVERTEX2 ); if( hres != D3D_OK ){ DbgOut( "bgdisp2 : Render : SetVertexShader error !!!\n" ); } hres = pd3dDevice->SetStreamSource( 0, m_VB, 0, sizeof(D3DTLVERTEX2) ); if( hres != D3D_OK ){ DbgOut( "bgdisp2 : Render : SetStreamSource error !!!\n" ); } } hres = pd3dDevice->SetIndices( m_IB ); if( hres != D3D_OK ){ DbgOut( "bgdisp2 : Render : SetIndices error !!!\n" ); } //hres = pd3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLESTRIP, // 0, // 4, // 0L, //m_dispIndices, // 2 //); hres = pd3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, BGTLVNUM, 0L, //m_dispIndices, (BGUNUM - 1) * (BGVNUM - 1) * 2 //m_numPrim ); if( FAILED( hres ) ){ DbgOut( "Render error !!! bgdisp\n" ); ret = 1; } if( multitexok != 0 ){ if( g_curtex1 != NULL ){ pd3dDevice->SetTexture( 1, NULL ); g_curtex1 = NULL; } if( g_cop1 != D3DTOP_DISABLE ){ pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE ); g_cop1 = D3DTOP_DISABLE; } } //pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP ); //pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP ); return ret; }
static int immersion_vibrator_resume(struct platform_device *pdev) { DbgOut((KERN_INFO "tspdrv: resume.\n")); return 0; /* can resume */ }
int CIM2File::GetFloatFromLine( int lineleng, int pos, int* lengptr, int* isendptr, float* floatptr ) { //isend は、要素の読み込み前に、終端0が現れたときに1にセットさする。 *isendptr = 0; //非数字部分を読み飛ばす。 int stepnum = 0; char curc = m_line[pos]; int minusflag = 0;//数字の直前に'-'があるかどうかのフラグ。 while( isdigit( curc ) == 0 ){ stepnum++; if( (pos + stepnum) >= lineleng ){ *isendptr = 1; return 0; } if( curc == '-' ){ minusflag = 1; }else{ minusflag = 0; } curc = m_line[ pos + stepnum ]; } // データ長を求める int startpos; startpos = pos + stepnum; int endpos = startpos; while( (endpos < lineleng) && ( (isdigit( curc ) != 0) || (curc == '.') ) ){ endpos++; curc = m_line[ endpos ]; } int dataleng; dataleng = endpos - startpos; if( dataleng >= 256 ){ DbgOut( "IM2file : GetFloatData : dataleng toot long error %d!!!\n", dataleng ); _ASSERT( 0 ); return 1; } // 文字列を番号に変換。 char seristr[256]; strncpy_s( seristr, 256, m_line + startpos, dataleng ); seristr[dataleng] = 0; if( minusflag == 1 ){ *floatptr = (float)(-atof( seristr )); }else{ *floatptr = (float)(atof( seristr )); } *lengptr = stepnum + dataleng; return 0; }
int CExtLineIO::CreateLine( CTreeHandler2* lpth, CShdHandler* lpsh, CMotHandler* lpmh, D3DXVECTOR3* pptr, int pointnum, int maxpointnum, int linekind ) { int ret; m_lpth = lpth; m_lpsh = lpsh; m_lpmh = lpmh; InitLoadParams(); ret = m_lpth->Start( 0 ); if( ret ){ _ASSERT( 0 ); return 1; } befseri = curseri; curseri = 1;// 0は、CreateHandlerで作成済 befdepth = curdepth; curdepth = 1;// 0は、CreateHandlerで作成済 befshdtype = curshdtype; curshdtype = SHDEXTLINE; char lname[1024]; ZeroMemory( lname, 1024 ); SYSTEMTIME systime; GetLocalTime( &systime ); sprintf_s( lname, 1024, "Line_%d_%d_%d_%d_%d_%d_%d", systime.wYear, systime.wMonth, systime.wDay, systime.wHour, systime.wMinute, systime.wSecond, systime.wMilliseconds ); ret = AddShape2Tree( lname ); if( ret ){ _ASSERT( 0 ); return 1; } ret = SetMeshInfo( &tempinfo, SHDEXTLINE, pointnum, maxpointnum, linekind ); if( ret ){ _ASSERT( 0 ); return 1; } ret = Init3DObj(); if( ret ){ _ASSERT( 0 ); return 1; } //////// CExtLine* curline; CShdElem* curselem; curselem = (*m_lpsh)( curseri ); if( !curselem ){ _ASSERT( 0 ); return 1; } curline = curselem->extline; if( !curline ){ _ASSERT( 0 ); return 1; } int pno; int epid; for( pno = 0; pno < pointnum; pno++ ){ ret = curline->AddExtPoint( -1, 1, &epid ); if( ret || (epid < 0) ){ DbgOut( "extlineio : curline AddExtPoint error !!!\n" ); _ASSERT( 0 ); return 1; } ret = curline->SetExtPointPos( epid, pptr + pno ); if( ret ){ DbgOut( "extlineio : curline SetExtPointPos error !!!\n "); _ASSERT( 0 ); return 1; } } //////// ret = m_lpsh->SetChain( 0 ); if( ret ){ _ASSERT( 0 ); return 1; } ret = m_lpsh->SetColors(); if( ret ){ _ASSERT( 0 ); return 1; } ret = m_lpmh->SetChain( 0 ); if( ret ){ _ASSERT( 0 ); return 1; } //////////// m_lpmh->m_curbs.visibleflag = 1;//!!!!!!!!!!!! return 0; }
int CIM2File::LoadIM2Binary() { int ret; int isend = 0; while( !isend && (im2buf.pos < im2buf.bufleng) ){ IM2HEADER im2h; ZeroMemory( &im2h, sizeof( IM2HEADER ) ); ret = LoadUCharData( (unsigned char*)&im2h, sizeof( IM2HEADER ) ); if( ret ){ DbgOut( "im2file : LoadIM2Binary : im2h load error !!!\n" ); _ASSERT( 0 ); return 1; } int cmp0; cmp0 = strcmp( im2h.name, im2endmark ); if( cmp0 == 0 ){ isend = 1; break; } int dispseri = 0; ret = m_lpth->GetDispObjNoByName( im2h.name, &dispseri, m_lpsh, 0 ); CShdElem* selem = 0; CInfElem* ieptr = 0; if( dispseri > 0 ){ selem = (*m_lpsh)( dispseri ); _ASSERT( selem ); switch( selem->type ){ case SHDPOLYMESH: if( selem->polymesh && (im2h.vertnum <= selem->polymesh->meshinfo->m) ) ieptr = selem->polymesh->m_IE; break; case SHDPOLYMESH2: if( selem->polymesh2 && (im2h.vertnum <= selem->polymesh2->optpleng) ) ieptr = selem->polymesh2->m_IE; break; default: ieptr = 0; break; } } if( ieptr ){ selem->m_loadbimflag = 1;//!!!!!!!!!!!!!!!!!!!!! } int vertno; for( vertno = 0; vertno < im2h.vertnum; vertno++ ){ INFELEMHEADER ieh; ZeroMemory( &ieh, sizeof( INFELEMHEADER ) ); ret = LoadUCharData( (unsigned char*)&ieh, sizeof( INFELEMHEADER ) ); if( ret ){ DbgOut( "im2file : LoadIM2Binary : ieh load error !!!\n" ); _ASSERT( 0 ); return 1; } if( ieptr ){ (ieptr + vertno)->normalizeflag = ieh.normalizeflag; (ieptr + vertno)->DestroyIE(); } if( m_version == 4 ){ int infno; for( infno = 0; infno < ieh.infnum; infno++ ){ INFIM2 infim2; ZeroMemory( &infim2, sizeof( INFIM2 ) ); ret = LoadUCharData( (unsigned char*)&infim2, sizeof( INFIM2 ) ); if( ret ){ DbgOut( "im2file : LoadIM2Binary : sie load error !!!\n" ); _ASSERT( 0 ); return 1; } int boneseri = 0; m_lpth->GetBoneNoByName( infim2.bonename, &boneseri, m_lpsh, 0 ); //ジョイントの番号ではなかった場合は、AddInfしない。!!!!!!!!!!! if( ieptr && (boneseri > 0) ){ INFELEM setIE; setIE.bonematno = boneseri; setIE.childno = boneseri; setIE.kind = infim2.kind; setIE.userrate = infim2.userrate; setIE.orginf = infim2.orginf; setIE.dispinf = infim2.dispinf; ret = (ieptr + vertno)->AddInfElem( setIE ); if( ret ){ DbgOut( "im2file : LoadIM2Binary : ie AddInfElem error !!!\n" ); _ASSERT( 0 ); return 1; } } } }else{ int infno; for( infno = 0; infno < ieh.infnum; infno++ ){ SIGINFELEM sie; ZeroMemory( &sie, sizeof( SIGINFELEM ) ); ret = LoadUCharData( (unsigned char*)&sie, sizeof( SIGINFELEM ) ); if( ret ){ DbgOut( "im2file : LoadIM2Binary : sie load error !!!\n" ); _ASSERT( 0 ); return 1; } int sericheck; if( (sie.childno < m_lpsh->s2shd_leng) && (sie.bonematno < m_lpsh->s2shd_leng) ){ //0以下はダミーもあるためOKとする。 sericheck = 1; }else{ sericheck = 0; } int childcheck = 0; if( sericheck == 1 ){ if( sie.childno > 0 ){ CShdElem* childelem; childelem = (*m_lpsh)( sie.childno ); if( childelem->IsJoint() && (childelem->type != SHDMORPH) ){ childcheck = 1; }else{ childcheck = 0; } }else{ childcheck = 1;// ダミーもOK } } int bonecheck = 0; if( m_version == 2 ){ if( sericheck == 1 ){ if( sie.bonematno > 0 ){ CShdElem* boneelem; boneelem = (*m_lpsh)( sie.bonematno ); if( boneelem->IsJoint() && (boneelem->type != SHDMORPH) ){ bonecheck = 1; }else{ bonecheck = 0; } }else{ bonecheck = 1;// ダミーもOK } } }else{ bonecheck = 1; } //ジョイントの番号ではなかった場合は、AddInfしない。!!!!!!!!!!! if( ieptr && (childcheck == 1) && (bonecheck == 1) ){ INFELEM setIE; if( m_version == 2 ){ if( sie.childno > 0 ){ setIE.bonematno = sie.childno;//!!!!!!! }else{ setIE.bonematno = sie.bonematno; } }else{ setIE.bonematno = sie.bonematno; } setIE.childno = sie.childno; //setIE.bonematno = sie.bonematno; setIE.kind = sie.kind; setIE.userrate = sie.userrate; setIE.orginf = sie.orginf; setIE.dispinf = sie.dispinf; ret = (ieptr + vertno)->AddInfElem( setIE ); if( ret ){ DbgOut( "im2file : LoadIM2Binary : ie AddInfElem error !!!\n" ); _ASSERT( 0 ); return 1; } } } } } } return 0; }
static void platform_release(struct device *dev) { DbgOut((KERN_INFO "tspdrv: platform_release.\n")); }
int CIM2File::WritePolyMesh2IM2( CShdElem* selem, char* name ) { int ret; IM2HEADER im2h; ZeroMemory( &im2h, sizeof( IM2HEADER ) ); if( !name ){ DbgOut( "im2file : WritePolyMesh2IM2 : name error !!!\n" ); _ASSERT( 0 ); return 1; } int leng; leng = (int)strlen( name ); if( (leng <= 0) || (leng >= 256) ){ DbgOut( "im2file : WritePolyMesh2IM2 : name leng error !!!\n" ); _ASSERT( 0 ); return 1; } strcpy_s( im2h.name, 256, name ); _ASSERT( selem->polymesh2 ); im2h.vertnum = selem->polymesh2->optpleng; ret = WriteUCharData( (unsigned char*)&im2h, sizeof( IM2HEADER ) ); if( ret ){ DbgOut( "im2file : WritePolyMesh2IM2 : im2header write error !!!\n" ); _ASSERT( 0 ); return 1; } _ASSERT( selem->polymesh2->m_IE ); INFELEMHEADER ieh; //SIGINFELEM sie; INFIM2 infim2; int vno; CInfElem* curie; int infno, infnum; INFELEM* pIE; for( vno = 0; vno < im2h.vertnum; vno++ ){ curie = selem->polymesh2->m_IE + vno; infnum = curie->infnum; ZeroMemory( &ieh, sizeof( INFELEMHEADER ) ); ieh.infnum = infnum; ieh.normalizeflag = curie->normalizeflag; ret = WriteUCharData( (unsigned char*)&ieh, sizeof( INFELEMHEADER ) ); if( ret ){ DbgOut( "im2file : WritePolyMesh2IM2 : ieh write error !!!\n" ); _ASSERT( 0 ); return 1; } for( infno = 0; infno < infnum; infno++ ){ ZeroMemory( &infim2, sizeof( INFIM2 ) ); ret = m_lpsh->GetInfElem( selem->serialno, vno, infno, &pIE ); if( ret || !pIE ){ DbgOut( "im2file : WritePolyMesh2IM2 : sh GetInfElem error !!!\n" ); _ASSERT( 0 ); return 1; } if( pIE->childno <= 0 ){ _ASSERT( 0 ); return 1; } CTreeElem2* te = (*m_lpth)( pIE->childno ); _ASSERT( te ); strcpy_s( infim2.bonename, 256, te->name ); infim2.kind = pIE->kind; infim2.userrate = pIE->userrate; infim2.orginf = pIE->orginf; infim2.dispinf = pIE->dispinf; ret = WriteUCharData( (unsigned char*)&infim2, sizeof( INFIM2 ) ); if( ret ){ DbgOut( "im2file : WritePolyMesh2IM2 : sie write error !!!\n" ); _ASSERT( 0 ); return 1; } } } return 0; }
static int ioctl( struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg ) { #ifdef QA_TEST int i; #endif DbgOut(( "[tspdrv] : ioctl cmd = %d %x\n", cmd, cmd )); switch ( cmd ) { case TSPDRV_STOP_KERNEL_TIMER: /* ** As we send one sample ahead of time, we need to finish playing the last sample ** before stopping the timer. So we just set a flag here. */ if ( true == g_bIsPlaying ) g_bStopRequested = true; #ifdef VIBEOSKERNELPROCESSDATA /* Last data processing to disable amp and stop timer */ VibeOSKernelProcessData(NULL); #endif #ifdef QA_TEST if ( g_nForceLogIndex ) { for ( i=0; i<g_nForceLogIndex; i++ ) { printk( "<6>%d\t%d\n", g_nTime, g_nForceLog[i] ); g_nTime += TIME_INCREMENT; } } g_nTime = 0; g_nForceLogIndex = 0; #endif g_bIsPlaying = false; break; case TSPDRV_MAGIC_NUMBER: file->private_data = (void*)TSPDRV_MAGIC_NUMBER; break; case TSPDRV_ENABLE_AMP: ImmVibeSPI_ForceOut_AmpEnable( arg ); DbgRecorderReset( ( arg ) ); DbgRecord( ( arg,";------- TSPDRV_ENABLE_AMP ---------\n" ) ); break; case TSPDRV_DISABLE_AMP: /* Small fix for now to handle proper combination of TSPDRV_STOP_KERNEL_TIMER and TSPDRV_DISABLE_AMP together */ /* If a stop was requested, ignore the request as the amp will be disabled by the timer proc when it's ready */ if( ! g_bStopRequested ) { ImmVibeSPI_ForceOut_AmpDisable( arg ); } break; case TSPDRV_GET_NUM_ACTUATORS: return NUM_ACTUATORS; } // end of switch return 0; }
int CIM2File::LoadIM2File( char* filename, CTreeHandler2* lpth, CShdHandler* lpsh, CMotHandler* lpmh ) { int ret = 0; m_lpth = lpth; m_lpsh = lpsh; m_lpmh = lpmh; //////////////////////////////////// m_hfile = CreateFile( (LPCTSTR)filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL ); if( m_hfile == INVALID_HANDLE_VALUE ){ DbgOut( "IM2File : LoadIM2File : CreateFile : INVALID_HANDLE_VALUE error !!!\n" ); return D3DAPPERR_MEDIANOTFOUND;//!!!!!!!! } ret = InitIM2BUF(); if( ret ){ DbgOut( "IM2File : LoadIM2File : InitIM2BUF error !!!\n" ); _ASSERT( 0 ); goto ldim2exit; } m_version = CheckFileHeader(); if( m_version == 0 ){ DbgOut( "IM2File : LoadIM2File : CheckFileHeader error !!!\n" ); _ASSERT( 0 ); goto ldim2exit; } //////////////////////////////////// if( (m_version == 1) && (lpsh->m_im2enableflag == 0) ){ DbgOut( "im2file : LoadIM2File : not support error !!!\n" ); DbgOut( "see : http://www5d.biglobe.ne.jp/~ochikko/rdb2_im2file.htm !!!\n" ); _ASSERT( 0 ); goto ldim2exit; } //////////////////////////////////// if( (m_version == 2) || (m_version == 3) || (m_version == 4) ){ int ldleng; LoadLine( &ldleng );//fileheader読み込み ret = LoadIM2Binary(); if( ret ){ DbgOut( "im2file : LoadIM2File : LoadIM2Binary error !!!\n" ); _ASSERT( 0 ); } goto ldim2exit; } //////////////////////// /////// 以下、旧バージョン ////////// ret = GetFirstJointNo( &m_firstseri );//InitIM2BUFより後で。m_firstseri if( ret ){ DbgOut( "IM2File : LoadIM2File : GetFirstJointNo error !!!\n" ); _ASSERT( 0 ); goto ldim2exit; } //IM2_NUTRAL, //IM2_LOADNAME, //IM2_LOADIM2, //IM2_FINISH, int loadmode; int loadflag; loadmode = IM2_NUTRAL; loadflag = 1; while( loadflag ){ switch( loadmode ){ case IM2_NUTRAL: ret = GetLoadMode( &loadmode ); if( ret ){ DbgOut( "IM2File : LoadIM2File : GetLoadMode error !!!\n" ); _ASSERT( 0 ); loadflag = 0; } break; case IM2_FINISH: loadflag = 0; break; case IM2_LOADNAME: ret = LoadPartName( &loadmode ); if( ret ){ DbgOut( "IM2File : LoadIM2File : LoadPartName error !!!\n" ); _ASSERT( 0 ); goto ldim2exit; } break; case IM2_LOADIM2: ret = LoadIM2( &loadmode ); if( ret ){ DbgOut( "IM2File : LoadIM2File : LoadIM2 error !!!\n" ); _ASSERT( 0 ); goto ldim2exit; } break; default: DbgOut( "IM2File : LoadIM2File : loadmode error !!!\n" ); _ASSERT( 0 ); loadflag = 0; break; } } ret = lpsh->CreateSkinMat( -1, 1 ); if( ret ){ DbgOut( "IM2File : LoadIM2File : sh CreateSkinMat error !!!\n" ); _ASSERT( 0 ); return 1; } goto ldim2exit; ldim2exit: // selem m_loadbimflagの処理 if( ret == 0 ){ //本セット int seri; CShdElem* se; for( seri = 0; seri < m_lpsh->s2shd_leng; seri++ ){ se = (*m_lpsh)( seri ); if( se->m_loadbimflag == 1 ) se->m_loadbimflag = 2;//!!!!!!! } }else{ //セット取り消し int seri; CShdElem* se; for( seri = 0; seri < m_lpsh->s2shd_leng; seri++ ){ se = (*m_lpsh)( seri ); if( se->m_loadbimflag == 1 ) se->m_loadbimflag = 0;//!!!!!!! } } if( m_hfile != INVALID_HANDLE_VALUE ){ CloseHandle( m_hfile ); m_hfile = INVALID_HANDLE_VALUE; } if( im2buf.buf ){ free( im2buf.buf ); im2buf.buf = 0; im2buf.bufleng = 0; im2buf.pos = 0; im2buf.isend = 0; } return ret; }
static int resume(struct platform_device *pdev) { DbgOut((DBL_ERROR, "tspdrv: resume.\n")); return 0; /* can resume */ }
int CIM2File::LoadPartName( int* modeptr ) { IM2ELEMInit( 1 ); int ret; int ldleng; ret = LoadLine( &ldleng ); if( ret ){ DbgOut( "IM2File : LoadPartName : LoadLine error !!!\n" ); _ASSERT( 0 ); return 1; } if( im2buf.isend != 0 ){ *modeptr = IM2_FINISH; return 0; } int cmp; cmp = strcmp( m_line, partendstr ); if( cmp == 0 ){ *modeptr = IM2_NUTRAL; return 0; } char* endchar; endchar = strchr( m_line, '\r' ); if( endchar ){ int nameleng; nameleng = (int)( endchar - m_line ); strncpy_s( curim2elem.partname, IM2LINELEN, m_line, nameleng ); curim2elem.partname[nameleng] = 0; }else{ strcpy_s( curim2elem.partname, IM2LINELEN, m_line ); } DbgOut( "im2file : LoadPartName : name %s\n", curim2elem.partname ); ///////// //ret = m_lpth->GetPartNoByName( curim2elem.partname, &(curim2elem.serialno) ); ret = m_lpth->GetDispObjNoByName( curim2elem.partname, &(curim2elem.serialno), m_lpsh, 1 ); if( ret ){ DbgOut( "IM2file : LoadPartName : lpth GetDispObjNoByName error !!!\n" ); _ASSERT( 0 ); return 1; } if( curim2elem.serialno <= 0 ){ DbgOut( "IM2file : LoadPartName : invalid partname , serialno not found error %s!!!\n", curim2elem.partname ); _ASSERT( 0 ); //return 1; m_invalidnameflag = 1;//!!!!!!!!!!!!!!!!!! }else{ m_invalidnameflag = 0; } ////////// *modeptr = IM2_LOADIM2; return 0; }
static __devinit int tspdrv_probe(struct platform_device *pdev) { int ret, i, rc; /* initialized below */ DbgOut((KERN_INFO "tspdrv: tspdrv_probe.\n")); motor_min_strength = g_nlra_gp_clk_n*MOTOR_MIN_STRENGTH/100; if(!pdev->dev.of_node){ DbgOut(KERN_ERR "tspdrv: tspdrv probe failed, DT is NULL"); return -ENODEV; } rc = tspdrv_parse_dt(pdev); if(rc) return rc; #if defined(CONFIG_MACH_HLTEDCM) || defined(CONFIG_MACH_HLTEKDI) || defined(CONFIG_MACH_JS01LTEDCM) virt_mmss_gp1_base = ioremap(MSM_MMSS_GP3_BASE,0x28); #else virt_mmss_gp1_base = ioremap(MSM_MMSS_GP1_BASE,0x28); #endif if (!virt_mmss_gp1_base) panic("tspdrv : Unable to ioremap MSM_MMSS_GP1 memory!"); #if defined(CONFIG_MOTOR_DRV_MAX77803) || defined(CONFIG_MOTOR_DRV_MAX77804K) vibrator_drvdata.power_onoff = max77803_haptic_power_onoff; #else vibrator_drvdata.power_onoff = NULL; #endif vibrator_drvdata.pwm_dev = NULL; #ifdef IMPLEMENT_AS_CHAR_DRIVER g_nmajor = register_chrdev(0, MODULE_NAME, &fops); if (g_nmajor < 0) { DbgOut((KERN_ERR "tspdrv: can't get major number.\n")); ret = g_nmajor; iounmap(virt_mmss_gp1_base); return ret; } #else ret = misc_register(&miscdev); if (ret) { DbgOut((KERN_ERR "tspdrv: misc_register failed.\n")); iounmap(virt_mmss_gp1_base); return ret; } #endif DbgRecorderInit(()); vibetonz_clk_on(&pdev->dev); ImmVibeSPI_ForceOut_Initialize(); VibeOSKernelLinuxInitTimer(); /* Get and concatenate device name and initialize data buffer */ g_cchdevice_name = 0; for (i = 0; i < NUM_ACTUATORS; i++) { char *szName = g_szdevice_name + g_cchdevice_name; ImmVibeSPI_Device_GetName(i, szName, VIBE_MAX_DEVICE_NAME_LENGTH); /* Append version information and get buffer length */ strlcat(szName, VERSION_STR, sizeof(VERSION_STR)); g_cchdevice_name += strnlen(szName, sizeof(szName)); g_samples_buffer[i].nindex_playing_buffer = -1;/* Not playing */ g_samples_buffer[i].actuator_samples[0].nbuffer_size = 0; g_samples_buffer[i].actuator_samples[1].nbuffer_size = 0; } wake_lock_init(&vib_wake_lock, WAKE_LOCK_SUSPEND, "vib_present"); vibetonz_start(); return 0; }
int CIM2File::ParseIM2Line() { int ret; int ldleng; int pos = 0; int lineleng; lineleng = (int)strlen( m_line ); int isend; IM2ELEMInit( 0 );//!!!! // 番号が、 , で区切られている。 int* dstptrlist[3]; dstptrlist[0] = &(curim2elem.vertno); dstptrlist[1] = &(curim2elem.boneno1); dstptrlist[2] = &(curim2elem.boneno2); char templine[IM2LINELEN]; int getno; for( getno = 0; getno < 4; getno++ ){ if( pos >= lineleng ){ DbgOut( "IM2File : ParseIM2Line : pos overflow error %d!!! return\n", getno ); _ASSERT( 0 ); return 1; } if( getno < 3 ){ ret = GetIntFromLine( lineleng, pos, &ldleng, &isend, dstptrlist[getno] ); if( ret ){ DbgOut( "IM2File : ParseIM2Line : GetIntFromLine error !!!\n" ); _ASSERT( 0 ); return 1; } if( isend != 0 ){ DbgOut( "IM2file : ParseIM2Line : getint %d data is too short error !!!\n", getno ); _ASSERT( 0 ); return 1; } }else{ templine[0] = 0; ret = GetAlnumFromLine( lineleng, pos, &ldleng, &isend, templine ); if( ret ){ DbgOut( "IM2File : ParseIM2Line : GetFloatFromLine error !!!\n" ); _ASSERT( 0 ); return 1; } if( isend != 0 ){ DbgOut( "IM2file : ParseIM2Line : get alnum data is too short error !!!\n" ); _ASSERT( 0 ); return 1; } //m_calcmodeのセット int cmp0, cmp1; cmp0 = strcmp( calcstr0, templine ); cmp1 = strcmp( calcstr1, templine ); if( cmp0 == 0 ){ curim2elem.calcmode = CALCMODE_NOSKIN0; }else{ if( cmp1 == 0 ){ curim2elem.calcmode = CALCMODE_ONESKIN0; }else{ DbgOut( "im2file : ParseIM2Line : invalid calcmode : set default value warning !!!\n" ); _ASSERT( 0 ); curim2elem.calcmode = CALCMODE_ONESKIN0; } } } if( isend != 0 ){ break; } pos += ldleng; } curim2elem.boneno1 += m_firstseri; curim2elem.boneno2 += m_firstseri; ////////// boneelemのセット CShdElem* selem; selem = (*m_lpsh)( curim2elem.serialno ); if( !selem ){ DbgOut( "IM2file : ParseIM2Line : selem NULL error %d !!!\n", curim2elem.serialno ); _ASSERT( 0 ); return 1; } if( selem->type == SHDPOLYMESH2 ){ CPolyMesh2* pm2; pm2 = selem->polymesh2; if( !pm2 ){ DbgOut( "IM2File : ParseIM2Line : pm2 NULL error !!!\n" ); _ASSERT( 0 ); return 1; } CMeshInfo* miptr; miptr = selem->GetMeshInfo(); if( !miptr ){ DbgOut( "IM2File : ParseIM2File : meshinfo NULL error !!!\n" ); _ASSERT( 0 ); return 1; } if( ((curim2elem.vertno < 0) && (curim2elem.vertno != -1)) || (curim2elem.vertno >= miptr->n * 3) ){ DbgOut( "IM2File : ParseIM2File : vertno error !!!\n" ); _ASSERT( 0 ); return 1; } //if( curim2elem.vertno != -1 ){ // curim2elem.vertno = *(pm2->oldpno2optpno + curim2elem.vertno);//!!!!!!!!!!! //} int oldno; int orgno; int optno; int bufleng; bufleng = pm2->meshinfo->n * 3; orgno = curim2elem.vertno; int* orgnobuf; orgnobuf = pm2->orgnobuf; if( !orgnobuf ){ DbgOut( "im2file : ParseIM2File : pm2 : orgnobuf not exist error !!!\n" ); _ASSERT( 0 ); return 1; } for( oldno = 0; oldno < bufleng; oldno++ ){ if( *( orgnobuf + oldno ) == orgno ){ optno = *( pm2->oldpno2optpno + oldno ); ret = selem->SetBIM( m_lpsh, optno, curim2elem.boneno1, curim2elem.boneno2, curim2elem.calcmode ); if( ret ){ DbgOut( "IM2file : ParseIM2Line : selem SetBIM error !!!\n" ); _ASSERT( 0 ); return 1; } } } }else if( selem->type == SHDPOLYMESH ){ CMeshInfo* miptr; miptr = selem->GetMeshInfo(); if( !miptr ){ DbgOut( "IM2File : ParseIM2File : meshinfo NULL error !!!\n" ); _ASSERT( 0 ); return 1; } //if( ((curim2elem.vertno < 0) && (curim2elem.vertno != -1)) || (curim2elem.vertno >= miptr->m) ){ // DbgOut( "IM2File : ParseIM2File : vertno error !!!\n" ); // _ASSERT( 0 ); // return 1; //} if( (curim2elem.vertno < 0) && (curim2elem.vertno != -1) ){ DbgOut( "IM2File : ParseIM2File : pm vertno error !!!\n" ); _ASSERT( 0 ); return 1; } CPolyMesh* pm; pm = selem->polymesh; if( !pm ){ DbgOut( "IM2File : ParseIM2File : pm not exist error !!!\n" ); _ASSERT( 0 ); return 1; } int* orgnobuf; orgnobuf = pm->orgnobuf; if( !orgnobuf ){ DbgOut( "IM2File : ParseIM2File : orgnobuf not exist error !!!\n" ); _ASSERT( 0 ); return 1; } int optno = -999; int oldno; for( oldno = 0; oldno < miptr->m; oldno++ ){ if( *( orgnobuf + oldno ) == curim2elem.vertno ){ optno = oldno; break; } } if( optno != -999 ){ ret = selem->SetBIM( m_lpsh, optno, curim2elem.boneno1, curim2elem.boneno2, curim2elem.calcmode ); if( ret ){ DbgOut( "IM2file : ParseIM2Line : selem SetBIM error !!!\n" ); _ASSERT( 0 ); return 1; } } }else{ DbgOut( "IM2File : PrseIM2File : selem type error !!!\n" ); _ASSERT( 0 ); return 1; } selem->m_loadbimflag = 1; return 0; }
static int resume(struct platform_device *pdev) { /* Restart system timers */ DbgOut(KERN_DEBUG "tspdrv: %s.\n", __func__); return 0; }
int CIM2File::WriteIM2File( char* filename, int srcformqo, CTreeHandler2* lpth, CShdHandler* lpsh ) { int ret = 0; if( !lpth || !lpsh ){ DbgOut( "IM2File : WriteIM2File : handler NULL error !!!\n" ); _ASSERT( 0 ); return 1; } m_lpth = lpth; m_lpsh = lpsh; m_formqo = srcformqo; ////////////////// //ボーンが1個も無いときは、出力しない。 int bonenum = 0; ret = lpsh->CheckBoneNum( &bonenum ); if( ret ){ DbgOut( "im2file : WriteIM2File : sh CheckBoneNum error !!!\n" ); _ASSERT( 0 ); return 1; } if( bonenum == 0 ){ DbgOut( "im2file : WriteIM2File : bonenum == 0 : return 0 !!!\n" ); MessageBox( NULL, "階層構造を持ったジョイントが一つもありません。\nジョイントに階層構造を作ってから、再試行してください。", "階層構造がありません", MB_OK ); //_ASSERT( 0 ); return 0; } /////////////////// m_hfile = CreateFile( (LPCTSTR)filename, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_FLAG_SEQUENTIAL_SCAN, NULL ); if( m_hfile == INVALID_HANDLE_VALUE ){ DbgOut( "IM2File : WriteIM2File : file open error !!!\n" ); _ASSERT( 0 ); ret = 1; goto im2fexit; } int sameno; sameno = CheckSameName(); if( sameno >= 0 ){ DbgOut( "im2file : WriteIM2File : CheckSameName error !!!\n" ); _ASSERT( 0 ); char messtr1[1024]; strcpy_s( messtr1, 1024, "同じオブジェクト名が複数あると、\n正しく、ファイルを作れません。\n名前を変えてから、再試行してください。\n" ); CTreeElem2* sametelem; sametelem = (*m_lpth)( sameno ); _ASSERT( sametelem ); ::MessageBox( NULL, messtr1, sametelem->name, MB_OK ); ret = 1; goto im2fexit; } Write2File( fileheaderstr4 ); int serino; CShdElem* selem; CTreeElem2* telem; //int dispflag, isbone; for( serino = 0; serino < m_lpsh->s2shd_leng; serino++ ){ selem = (*m_lpsh)( serino ); telem = (*m_lpth)( serino ); if( !selem || !telem ){ DbgOut( "IM2File : WriteIM2File : elem error %x %x !!!\n", selem, telem ); _ASSERT( 0 ); ret = 1; goto im2fexit; } if( (selem->type == SHDPOLYMESH) || (selem->type == SHDPOLYMESH2) ){ ret = WriteIM2( selem, telem ); if( ret ){ DbgOut( "IM2File : WriteIM2File : WriteIM2 error %d!!!\n", serino ); ret = 1; goto im2fexit; } } } //終わりの目印 IM2HEADER im2h; ZeroMemory( &im2h, sizeof( IM2HEADER ) ); strcpy_s( im2h.name, 256, im2endmark ); im2h.vertnum = 0; ret = WriteUCharData( (unsigned char*)&im2h, sizeof( IM2HEADER ) ); if( ret ){ DbgOut( "im2file : WriteIM2File : endmark write error !!!\n" ); _ASSERT( 0 ); ret = 1; goto im2fexit; } goto im2fexit; im2fexit: if( m_hfile != INVALID_HANDLE_VALUE ){ FlushFileBuffers( m_hfile ); SetEndOfFile( m_hfile ); CloseHandle( m_hfile ); m_hfile = INVALID_HANDLE_VALUE; } return ret; }
BOOL OnNotify( HWND ParentHwnd, LPNMHDR NmHdr, PTOASTER_PROP_PARAMS Params ) { SP_DEVINSTALL_PARAMS spDevInstall = {0}; TCHAR friendlyName[LINE_LEN] ={0}; BOOL fSuccess; switch (NmHdr->code) { case PSN_APPLY: // // Sent when the user clicks on Apply OR OK !! // GetDlgItemText(ParentHwnd, IDC_FRIENDLYNAME, friendlyName, LINE_LEN-1 ); friendlyName[LINE_LEN-1] = UNICODE_NULL; if(friendlyName[0]) { fSuccess = SetupDiSetDeviceRegistryProperty(Params->DeviceInfoSet, Params->DeviceInfoData, SPDRP_FRIENDLYNAME, (BYTE *)friendlyName, (lstrlen(friendlyName)+1) * sizeof(TCHAR) ); if(!fSuccess) { DbgOut("SetupDiSetDeviceRegistryProperty failed!"); break; } // // Inform setup about property change so that it can // restart the device. // spDevInstall.cbSize = sizeof(SP_DEVINSTALL_PARAMS); if (Params && SetupDiGetDeviceInstallParams(Params->DeviceInfoSet, Params->DeviceInfoData, &spDevInstall)) { // // If your device requires a reboot to restart, you can // specify that by setting DI_NEEDREBOOT as shown below // // if(NeedReboot) { // spDevInstall.Flags |= DI_PROPERTIES_CHANGE | DI_NEEDREBOOT; // } // spDevInstall.FlagsEx |= DI_FLAGSEX_PROPCHANGE_PENDING; SetupDiSetDeviceInstallParams(Params->DeviceInfoSet, Params->DeviceInfoData, &spDevInstall); } } return TRUE; default: return FALSE; } return FALSE; }
int CBgDisp2::CreateTexture( LPDIRECT3DDEVICE9 pd3dDevice ) { pd3dDevice->SetTexture( 0, NULL ); g_curtex0 = NULL; pd3dDevice->SetTexture( 1, NULL ); g_curtex1 = NULL; pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); g_cop0 = D3DTOP_MODULATE; // pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );//!!!! // g_aop0 = D3DTOP_MODULATE; pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE ); g_cop1 = D3DTOP_DISABLE; pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); g_aop0 = D3DTOP_SELECTARG1; pd3dDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );//!!!! g_aop1 = D3DTOP_DISABLE; int ret = 0; if( !g_texbnk ){ g_texbnk = new CTexBank( 1, D3DX_FILTER_LINEAR );//!!!!!!!!!!! if( !g_texbnk ){ DbgOut( "CBgDisp2 : CreateTexture : new CTexBank error !!!\n" ); _ASSERT( 0 ); return 1; } } if( *texname ){ ret = g_texbnk->AddName( 0, texname, transparent1, D3DPOOL_MANAGED ); _ASSERT( ret >= 0 ); if( ret < 0 ){ DbgOut( "bgdisp2 : CreateTexture : AddName 1 error !!!\n" ); } } if( *texname2 ){ ret = g_texbnk->AddName( 0, texname2, transparent2, D3DPOOL_MANAGED ); _ASSERT( ret >= 0 ); if( ret < 0 ){ DbgOut( "bgdisp2 : CreateTexture : AddName 2 error !!!\n" ); } } int texi1, texi2; texi1 = g_texbnk->GetTexNoByName( texname, transparent1 ); texi2 = g_texbnk->GetTexNoByName( texname2, transparent2 ); if( texi1 >= 0 ){ ret = g_texbnk->CreateTexData( texi1, pd3dDevice ); if( (ret != 0) && (ret != -2) ){ DbgOut( "BgDisp : g_texbnk : CreateTexData 1 error !!! set null texture\n" ); int ret2; ret2 = g_texbnk->SetTexData( texi1, NULL ); if( ret2 ){ _ASSERT( 0 ); return 1; } } } if( texi2 >= 0 ){ ret = g_texbnk->CreateTexData( texi2, pd3dDevice ); if( (ret != 0) && (ret != -2) ){ DbgOut( "BgDisp : g_texbnk : CreateTexData 2 error !!! set null texture\n" ); int ret2; ret2 = g_texbnk->SetTexData( texi2, NULL ); if( ret2 ){ _ASSERT( 0 ); return 1; } } } if( texi1 >= 0 ){ ret = g_texbnk->GetTexOrgSize( texi1, &fixx, &fixy ); if( ret ){ fixx = 256; fixy = 256; } }else{ fixx = 256; fixy = 256; } DbgOut( "BgDisp : CreateTexture : fixx %d, fixy %d\r\n", fixx, fixy ); return 0; }