vibrator: tspdrv: clean up codes

Change-Id: I85ecec9fb01e21ea0cdf3fda1c43851c26c7f552
This commit is contained in:
Devin Kim
2012-09-18 11:48:20 -07:00
committed by Iliyan Malchev
parent 85c85ee651
commit ace7135a0e
5 changed files with 185 additions and 219 deletions

View File

@@ -1,31 +1,28 @@
/* /*
** ========================================================================= * File: ImmVibeSPI.c
** File: *
** ImmVibeSPI.c * Description:
** * Device-dependent functions called by Immersion TSP API
** Description: * to control PWM duty cycle, amp enable/disable, save IVT file, etc...
** Device-dependent functions called by Immersion TSP API *
** to control PWM duty cycle, amp enable/disable, save IVT file, etc... * Portions Copyright (c) 2008-2010 Immersion Corporation. All Rights Reserved.
** *
** Portions Copyright (c) 2008-2010 Immersion Corporation. All Rights Reserved. * This file contains Original Code and/or Modifications of Original Code
** * as defined in and that are subject to the GNU Public License v2 -
** This file contains Original Code and/or Modifications of Original Code * (the 'License'). You may not use this file except in compliance with the
** as defined in and that are subject to the GNU Public License v2 - * License. You should have received a copy of the GNU General Public License
** (the 'License'). You may not use this file except in compliance with the * along with this program; if not, write to the Free Software Foundation, Inc.,
** License. You should have received a copy of the GNU General Public License * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or contact
** along with this program; if not, write to the Free Software Foundation, Inc., * TouchSenseSales@immersion.com.
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or contact *
** TouchSenseSales@immersion.com. * The Original Code and all software distributed under the License are
** * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
** The Original Code and all software distributed under the License are * EXPRESS OR IMPLIED, AND IMMERSION HEREBY DISCLAIMS ALL SUCH WARRANTIES,
** distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
** EXPRESS OR IMPLIED, AND IMMERSION HEREBY DISCLAIMS ALL SUCH WARRANTIES, * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see
** INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS * the License for the specific language governing rights and limitations
** FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see * under the License.
** the License for the specific language governing rights and limitations */
** under the License.
** =========================================================================
*/
#include <linux/io.h> #include <linux/io.h>
#include <linux/err.h> #include <linux/err.h>
@@ -37,18 +34,6 @@
#include <mach/msm_iomap.h> #include <mach/msm_iomap.h>
#include <mach/msm_xo.h> #include <mach/msm_xo.h>
#ifdef IMMVIBESPIAPI
#undef IMMVIBESPIAPI
#endif
#define IMMVIBESPIAPI static
/*
** This SPI supports only one actuator.
*/
#define NUM_ACTUATORS 1
#define PWM_DUTY_MAX 579 /* 13MHz / (579 + 1) = 22.4kHz */
static bool g_bAmpEnabled = false; static bool g_bAmpEnabled = false;
/* gpio and clock control for vibrator */ /* gpio and clock control for vibrator */
@@ -79,8 +64,6 @@ static bool g_bAmpEnabled = false;
#define GP_CLK_D_MAX GP_CLK_N_DEFAULT #define GP_CLK_D_MAX GP_CLK_N_DEFAULT
#define GP_CLK_D_HALF (GP_CLK_N_DEFAULT >> 1) #define GP_CLK_D_HALF (GP_CLK_N_DEFAULT >> 1)
#define MOTOR_AMP 120
static struct gpiomux_setting vibrator_suspend_cfg = { static struct gpiomux_setting vibrator_suspend_cfg = {
.func = GPIOMUX_FUNC_GPIO, .func = GPIOMUX_FUNC_GPIO,
@@ -174,7 +157,6 @@ static int vibrator_power_set(int enable)
pr_warn("%s: regulator_is_enabled failed\n", __func__); pr_warn("%s: regulator_is_enabled failed\n", __func__);
} }
//rc = regulator_set_voltage(vreg_l16, 3000000, 3000000);
rc = regulator_set_voltage(vreg_l16, 2800000, 2800000); rc = regulator_set_voltage(vreg_l16, 2800000, 2800000);
if(enable) { if(enable) {
@@ -257,7 +239,7 @@ static void vibrator_ic_enable_set(int enable)
/* /*
** Called to disable amp (disable output force) ** Called to disable amp (disable output force)
*/ */
IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_AmpDisable(VibeUInt8 nActuatorIndex) static VibeStatus ImmVibeSPI_ForceOut_AmpDisable(VibeUInt8 nActuatorIndex)
{ {
if (g_bAmpEnabled) { if (g_bAmpEnabled) {
@@ -276,7 +258,7 @@ IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_AmpDisable(VibeUInt8 nActuatorIndex
/* /*
** Called to enable amp (enable output force) ** Called to enable amp (enable output force)
*/ */
IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_AmpEnable(VibeUInt8 nActuatorIndex) static VibeStatus ImmVibeSPI_ForceOut_AmpEnable(VibeUInt8 nActuatorIndex)
{ {
if (!g_bAmpEnabled) { if (!g_bAmpEnabled) {
@@ -298,7 +280,7 @@ IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_AmpEnable(VibeUInt8 nActuatorIndex)
/* /*
** Called at initialization time to set PWM freq, disable amp, etc... ** Called at initialization time to set PWM freq, disable amp, etc...
*/ */
IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_Initialize(void) static VibeStatus ImmVibeSPI_ForceOut_Initialize(void)
{ {
int rc; int rc;
int gpio_motor_en = 0; int gpio_motor_en = 0;
@@ -347,7 +329,7 @@ IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_Initialize(void)
/* /*
** Called at termination time to set PWM freq, disable amp, etc... ** Called at termination time to set PWM freq, disable amp, etc...
*/ */
IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_Terminate(void) static VibeStatus ImmVibeSPI_ForceOut_Terminate(void)
{ {
DbgOut((KERN_DEBUG "ImmVibeSPI_ForceOut_Terminate.\n")); DbgOut((KERN_DEBUG "ImmVibeSPI_ForceOut_Terminate.\n"));
@@ -366,7 +348,7 @@ IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_Terminate(void)
/* /*
** Called by the real-time loop to set PWM duty cycle ** Called by the real-time loop to set PWM duty cycle
*/ */
IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_SetSamples(VibeUInt8 nActuatorIndex, VibeUInt16 nOutputSignalBitDepth, VibeUInt16 nBufferSizeInBytes, VibeInt8* pForceOutputBuffer) static VibeStatus ImmVibeSPI_ForceOut_SetSamples(VibeUInt8 nActuatorIndex, VibeUInt16 nOutputSignalBitDepth, VibeUInt16 nBufferSizeInBytes, VibeInt8* pForceOutputBuffer)
{ {
VibeInt8 nForce; VibeInt8 nForce;
@@ -405,22 +387,7 @@ IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_SetSamples(VibeUInt8 nActuatorIndex
/* /*
** Called to get the device name (device name must be returned as ANSI char) ** Called to get the device name (device name must be returned as ANSI char)
*/ */
IMMVIBESPIAPI VibeStatus ImmVibeSPI_Device_GetName(VibeUInt8 nActuatorIndex, char *szDevName, int nSize) static VibeStatus ImmVibeSPI_Device_GetName(VibeUInt8 nActuatorIndex, char *szDevName, int nSize)
{ {
#if 0
/* The following code is provided as a sample.
* Please modify as required.
*/
if ((!szDevName) || (nSize < 1))
return VIBE_E_FAIL;
DbgOut((KERN_DEBUG "ImmVibeSPI_Device_GetName.\n"));
strncpy(szDevName, "Generic Linux Device", nSize-1);
/* make sure the string is NULL terminated */
szDevName[nSize - 1] = '\0';
#endif
return VIBE_S_SUCCESS; return VIBE_S_SUCCESS;
} }

View File

@@ -1,36 +1,33 @@
/* /*
** ========================================================================= * File: VibeOSKernelLinuxHRTime.c
** File: *
** VibeOSKernelLinuxHRTime.c * Description:
** * High Resolution Time helper functions for Linux.
** Description: *
** High Resolution Time helper functions for Linux. * Portions Copyright (c) 2010-2011 Immersion Corporation. All Rights Reserved.
** *
** Portions Copyright (c) 2010-2011 Immersion Corporation. All Rights Reserved. * This file contains Original Code and/or Modifications of Original Code
** * as defined in and that are subject to the GNU Public License v2 -
** This file contains Original Code and/or Modifications of Original Code * (the 'License'). You may not use this file except in compliance with the
** as defined in and that are subject to the GNU Public License v2 - * License. You should have received a copy of the GNU General Public License
** (the 'License'). You may not use this file except in compliance with the * along with this program; if not, write to the Free Software Foundation, Inc.,
** License. You should have received a copy of the GNU General Public License * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or contact
** along with this program; if not, write to the Free Software Foundation, Inc., * TouchSenseSales@immersion.com.
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or contact *
** TouchSenseSales@immersion.com. * The Original Code and all software distributed under the License are
** * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
** The Original Code and all software distributed under the License are * EXPRESS OR IMPLIED, AND IMMERSION HEREBY DISCLAIMS ALL SUCH WARRANTIES,
** distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
** EXPRESS OR IMPLIED, AND IMMERSION HEREBY DISCLAIMS ALL SUCH WARRANTIES, * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see
** INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS * the License for the specific language governing rights and limitations
** FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see * under the License.
** the License for the specific language governing rights and limitations */
** under the License.
** =========================================================================
*/
/* /*
** Kernel high-resolution software timer is used as an example but another type * Kernel high-resolution software timer is used as an example but another type
** of timer (such as HW timer or standard software timer) might be used to achieve * of timer (such as HW timer or standard software timer) might be used to achieve
** the 5ms required rate. * the 5ms required rate.
*/ */
#ifndef CONFIG_HIGH_RES_TIMERS #ifndef CONFIG_HIGH_RES_TIMERS
#warning "The Kernel does not have high resolution timers enabled. Either provide a non hr-timer implementation of VibeOSKernelLinuxTime.c or re-compile your kernel with CONFIG_HIGH_RES_TIMERS=y" #warning "The Kernel does not have high resolution timers enabled. Either provide a non hr-timer implementation of VibeOSKernelLinuxTime.c or re-compile your kernel with CONFIG_HIGH_RES_TIMERS=y"
@@ -202,10 +199,11 @@ static void VibeOSKernelLinuxStartTimer(void)
return; return;
/* /*
** Use interruptible version of down to be safe * Use interruptible version of down to be safe
** (try to not being stuck here if the mutex is not freed for any reason) * (try to not being stuck here
*/ * if the mutex is not freed for any reason)
/* wait for the mutex to be freed by the timer */ * wait for the mutex to be freed by the timer
*/
res = down_interruptible(&g_hMutex); res = down_interruptible(&g_hMutex);
if (res != 0) { if (res != 0) {
DbgOut((KERN_INFO "VibeOSKernelLinuxStartTimer: down_interruptible interrupted by a signal.\n")); DbgOut((KERN_INFO "VibeOSKernelLinuxStartTimer: down_interruptible interrupted by a signal.\n"));

View File

@@ -1,37 +1,34 @@
/* /*
** ========================================================================= * File: VibeOSKernelLinuxTime.c
** File: *
** VibeOSKernelLinuxTime.c * Description:
** * Time helper functions for Linux.
** Description: *
** Time helper functions for Linux. * Portions Copyright (c) 2008-2011 Immersion Corporation. All Rights Reserved.
** *
** Portions Copyright (c) 2008-2011 Immersion Corporation. All Rights Reserved. * This file contains Original Code and/or Modifications of Original Code
** * as defined in and that are subject to the GNU Public License v2 -
** This file contains Original Code and/or Modifications of Original Code * (the 'License'). You may not use this file except in compliance with the
** as defined in and that are subject to the GNU Public License v2 - * License. You should have received a copy of the GNU General Public License
** (the 'License'). You may not use this file except in compliance with the * along with this program; if not, write to the Free Software Foundation, Inc.,
** License. You should have received a copy of the GNU General Public License * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or contact
** along with this program; if not, write to the Free Software Foundation, Inc., * TouchSenseSales@immersion.com.
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or contact *
** TouchSenseSales@immersion.com. * The Original Code and all software distributed under the License are
** * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
** The Original Code and all software distributed under the License are * EXPRESS OR IMPLIED, AND IMMERSION HEREBY DISCLAIMS ALL SUCH WARRANTIES,
** distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
** EXPRESS OR IMPLIED, AND IMMERSION HEREBY DISCLAIMS ALL SUCH WARRANTIES, * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see
** INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS * the License for the specific language governing rights and limitations
** FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see * under the License.
** the License for the specific language governing rights and limitations */
** under the License.
** =========================================================================
*/
#error "Please read the following statement" #error "Please read the following statement"
/* /*
** Kernel standard software timer is used as an example but another type * Kernel standard software timer is used as an example but another type
** of timer (such as HW timer or high-resolution software timer) might be used * of timer (such as HW timer or high-resolution software timer) might be used
** to achieve the 5ms required rate. * to achieve the 5ms required rate.
*/ */
#error "End of statement" #error "End of statement"
#if (HZ != 1000) #if (HZ != 1000)
@@ -96,8 +93,10 @@ static int VibeOSKernelProcessData(void* data)
((++g_nWatchdogCounter) > WATCHDOG_TIMEOUT)) { ((++g_nWatchdogCounter) > WATCHDOG_TIMEOUT)) {
VibeInt8 cZero[1] = {0}; VibeInt8 cZero[1] = {0};
/* Nothing to play for all actuators, /* Nothing to play for all actuators,
turn off the timer when we reach the watchdog tick count limit */ * turn off the timer when we reach
* the watchdog tick count limit
*/
ImmVibeSPI_ForceOut_SetSamples(i, 8, 1, cZero); ImmVibeSPI_ForceOut_SetSamples(i, 8, 1, cZero);
ImmVibeSPI_ForceOut_AmpDisable(i); ImmVibeSPI_ForceOut_AmpDisable(i);
VibeOSKernelLinuxStopTimer(); VibeOSKernelLinuxStopTimer();
@@ -194,9 +193,10 @@ static void VibeOSKernelLinuxStartTimer(void)
return; return;
/* /*
** Use interruptible version of down to be safe * Use interruptible version of down to be safe
** (try to not being stuck here if the mutex is not freed for any reason) * (try to not being stuck here
*/ * if the mutex is not freed for any reason)
*/
res = down_interruptible(&g_hMutex); /* wait for the mutex to be freed by the timer */ res = down_interruptible(&g_hMutex); /* wait for the mutex to be freed by the timer */
if (res != 0) { if (res != 0) {
DbgOut((KERN_INFO "VibeOSKernelLinuxStartTimer: down_interruptible interrupted by a signal.\n")); DbgOut((KERN_INFO "VibeOSKernelLinuxStartTimer: down_interruptible interrupted by a signal.\n"));
@@ -211,11 +211,13 @@ static void VibeOSKernelLinuxStopTimer(void)
g_bTimerStarted = false; g_bTimerStarted = false;
/* /*
** Stop the timer. * Stop the timer.
** Use del_timer vs. del_timer_sync * Use del_timer vs. del_timer_sync
** del_timer_sync may cause a Kernel "soft lockup" on multi-CPU platforms * del_timer_sync may cause a Kernel "soft lockup"
** as VibeOSKernelLinuxStopTimer is called from the timer tick handler. * on multi-CPU platforms
*/ * as VibeOSKernelLinuxStopTimer is called
* from the timer tick handler.
*/
del_timer(&g_timerList); del_timer(&g_timerList);
} }

View File

@@ -1,34 +1,27 @@
/* /*
** ========================================================================= * File: tspdrv.c
** File: *
** tspdrv.c * Description:
** * TouchSense Kernel Module main entry-point.
** Description: *
** TouchSense Kernel Module main entry-point. * Portions Copyright (c) 2008-2011 Immersion Corporation. All Rights Reserved.
** *
** Portions Copyright (c) 2008-2011 Immersion Corporation. All Rights Reserved. * This file contains Original Code and/or Modifications of Original Code
** * as defined in and that are subject to the GNU Public License v2 -
** This file contains Original Code and/or Modifications of Original Code * (the 'License'). You may not use this file except in compliance with the
** as defined in and that are subject to the GNU Public License v2 - * License. You should have received a copy of the GNU General Public License
** (the 'License'). You may not use this file except in compliance with the * along with this program; if not, write to the Free Software Foundation, Inc.,
** License. You should have received a copy of the GNU General Public License * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or contact
** along with this program; if not, write to the Free Software Foundation, Inc., * TouchSenseSales@immersion.com.
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or contact *
** TouchSenseSales@immersion.com. * The Original Code and all software distributed under the License are
** * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
** The Original Code and all software distributed under the License are * EXPRESS OR IMPLIED, AND IMMERSION HEREBY DISCLAIMS ALL SUCH WARRANTIES,
** distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
** EXPRESS OR IMPLIED, AND IMMERSION HEREBY DISCLAIMS ALL SUCH WARRANTIES, * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see
** INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS * the License for the specific language governing rights and limitations
** FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see * under the License.
** the License for the specific language governing rights and limitations */
** under the License.
** =========================================================================
*/
#ifndef __KERNEL__
#define __KERNEL__
#endif
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
@@ -232,17 +225,17 @@ static int release(struct inode *inode, struct file *file)
DbgOut((KERN_INFO "tspdrv: release.\n")); DbgOut((KERN_INFO "tspdrv: release.\n"));
/* /*
** Reset force and stop timer when the driver is closed, to make sure * Reset force and stop timer when the driver is closed, to make sure
** no dangling semaphore remains in the system, especially when the * no dangling semaphore remains in the system, especially when the
** driver is run outside of immvibed for testing purposes. * driver is run outside of immvibed for testing purposes.
*/ */
VibeOSKernelLinuxStopTimer(); VibeOSKernelLinuxStopTimer();
/* /*
** Clear the variable used to store the magic number to prevent * Clear the variable used to store the magic number to prevent
** unauthorized caller to write data. TouchSense service is the only * unauthorized caller to write data. TouchSense service is the only
** valid caller. * valid caller.
*/ */
file->private_data = (void*)NULL; file->private_data = (void*)NULL;
module_put(THIS_MODULE); module_put(THIS_MODULE);
@@ -277,9 +270,9 @@ static ssize_t write(struct file *file, const char *buf, size_t count, loff_t *p
*ppos = 0; /* file position not used, always set to 0 */ *ppos = 0; /* file position not used, always set to 0 */
/* /*
** Prevent unauthorized caller to write data. * Prevent unauthorized caller to write data.
** TouchSense service is the only valid caller. * TouchSense service is the only valid caller.
*/ */
if (file->private_data != (void*)TSPDRV_MAGIC_NUMBER) { if (file->private_data != (void*)TSPDRV_MAGIC_NUMBER) {
DbgOut((KERN_ERR "tspdrv: unauthorized write.\n")); DbgOut((KERN_ERR "tspdrv: unauthorized write.\n"));
return 0; return 0;
@@ -305,9 +298,9 @@ static ssize_t write(struct file *file, const char *buf, size_t count, loff_t *p
if ((i + SPI_HEADER_SIZE) >= count) { if ((i + SPI_HEADER_SIZE) >= count) {
/* /*
** Index is about to go beyond the buffer size. * Index is about to go beyond the buffer size.
** (Should never happen). * (Should never happen).
*/ */
DbgOut((KERN_EMERG "tspdrv: invalid buffer index.\n")); DbgOut((KERN_EMERG "tspdrv: invalid buffer index.\n"));
} }
@@ -352,7 +345,10 @@ static ssize_t write(struct file *file, const char *buf, size_t count, loff_t *p
/* Store the data in the free buffer of the given actuator */ /* 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)); 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 the no buffer is playing,prepare to play
* g_SamplesBuffer[pInputBuffer->nActuatorIndex]
* .actuatorSamples[nIndexFreeBuffer]
*/
if ( -1 == g_SamplesBuffer[pInputBuffer->nActuatorIndex].nIndexPlayingBuffer) { if ( -1 == g_SamplesBuffer[pInputBuffer->nActuatorIndex].nIndexPlayingBuffer) {
g_SamplesBuffer[pInputBuffer->nActuatorIndex].nIndexPlayingBuffer = nIndexFreeBuffer; g_SamplesBuffer[pInputBuffer->nActuatorIndex].nIndexPlayingBuffer = nIndexFreeBuffer;
g_SamplesBuffer[pInputBuffer->nActuatorIndex].nIndexOutputValue = 0; g_SamplesBuffer[pInputBuffer->nActuatorIndex].nIndexOutputValue = 0;
@@ -392,22 +388,24 @@ static int ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsig
switch (cmd) { switch (cmd) {
case TSPDRV_STOP_KERNEL_TIMER: case TSPDRV_STOP_KERNEL_TIMER:
/* /*
** As we send one sample ahead of time, we need to finish playing the last sample * As we send one sample ahead of time, we need to finish
** before stopping the timer. So we just set a flag here. * playing the last samplebefore stopping the timer.
*/ * So we just set a flag here.
*/
if (true == g_bIsPlaying) if (true == g_bIsPlaying)
g_bStopRequested = true; g_bStopRequested = true;
#ifdef VIBEOSKERNELPROCESSDATA #ifdef VIBEOSKERNELPROCESSDATA
/* Last data processing to disable amp and stop timer */ /* Last data processing to disable amp and stop timer */
VibeOSKernelProcessData(NULL); VibeOSKernelProcessData(NULL);
#endif #endif
#ifdef QA_TEST #ifdef QA_TEST
if (g_nForceLogIndex) { if (g_nForceLogIndex) {
for (i=0; i<g_nForceLogIndex; i++) { for (i = 0; i < g_nForceLogIndex; i++) {
printk("<6>%d\t%d\n", g_nTime, g_nForceLog[i]); printk(KERN_INFO "%d\t%d\n", g_nTime,
g_nForceLog[i]);
g_nTime += TIME_INCREMENT; g_nTime += TIME_INCREMENT;
} }
} }
@@ -423,12 +421,16 @@ static int ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsig
case TSPDRV_ENABLE_AMP: case TSPDRV_ENABLE_AMP:
ImmVibeSPI_ForceOut_AmpEnable(arg); ImmVibeSPI_ForceOut_AmpEnable(arg);
DbgRecorderReset((arg)); DbgRecorderReset((arg));
DbgRecord((arg,";------- TSPDRV_ENABLE_AMP ---------\n")); DbgRecord((arg,";TSPDRV_ENABLE_AMP\n"));
break; break;
case TSPDRV_DISABLE_AMP: case TSPDRV_DISABLE_AMP:
/* Small fix for now to handle proper combination of TSPDRV_STOP_KERNEL_TIMER and TSPDRV_DISABLE_AMP together */ /* Small fix for now to handle proper combination of
/* If a stop was requested, ignore the request as the amp will be disabled by the timer proc when it's ready */ * 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) { if (!g_bStopRequested) {
ImmVibeSPI_ForceOut_AmpDisable(arg); ImmVibeSPI_ForceOut_AmpDisable(arg);
} }

View File

@@ -1,30 +1,27 @@
/* /*
** ========================================================================= * File: tspdrv.h
** File: *
** tspdrv.h * Description:
** * Constants and type definitions for the TouchSense Kernel Module.
** Description: *
** Constants and type definitions for the TouchSense Kernel Module. * Portions Copyright (c) 2008-2010 Immersion Corporation. All Rights Reserved.
** *
** Portions Copyright (c) 2008-2010 Immersion Corporation. All Rights Reserved. * This file contains Original Code and/or Modifications of Original Code
** * as defined in and that are subject to the GNU Public License v2 -
** This file contains Original Code and/or Modifications of Original Code * (the 'License'). You may not use this file except in compliance with the
** as defined in and that are subject to the GNU Public License v2 - * License. You should have received a copy of the GNU General Public License
** (the 'License'). You may not use this file except in compliance with the * along with this program; if not, write to the Free Software Foundation, Inc.,
** License. You should have received a copy of the GNU General Public License * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or contact
** along with this program; if not, write to the Free Software Foundation, Inc., * TouchSenseSales@immersion.com.
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or contact *
** TouchSenseSales@immersion.com. * The Original Code and all software distributed under the License are
** * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
** The Original Code and all software distributed under the License are * EXPRESS OR IMPLIED, AND IMMERSION HEREBY DISCLAIMS ALL SUCH WARRANTIES,
** distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
** EXPRESS OR IMPLIED, AND IMMERSION HEREBY DISCLAIMS ALL SUCH WARRANTIES, * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see
** INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS * the License for the specific language governing rights and limitations
** FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see * under the License.
** the License for the specific language governing rights and limitations */
** under the License.
** =========================================================================
*/
#ifndef _TSPDRV_H #ifndef _TSPDRV_H
#define _TSPDRV_H #define _TSPDRV_H
@@ -41,7 +38,7 @@
#define TSPDRV_ENABLE_AMP _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 3) #define TSPDRV_ENABLE_AMP _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 3)
#define TSPDRV_DISABLE_AMP _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 4) #define TSPDRV_DISABLE_AMP _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 4)
#define TSPDRV_GET_NUM_ACTUATORS _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 5) #define TSPDRV_GET_NUM_ACTUATORS _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 5)
#define VIBE_MAX_DEVICE_NAME_LENGTH 64 #define VIBE_MAX_DEVICE_NAME_LENGTH 64
#define SPI_HEADER_SIZE 3 /* DO NOT CHANGE - SPI buffer header size */ #define SPI_HEADER_SIZE 3 /* DO NOT CHANGE - SPI buffer header size */
#define VIBE_OUTPUT_SAMPLE_SIZE 50 /* DO NOT CHANGE - maximum number of samples */ #define VIBE_OUTPUT_SAMPLE_SIZE 50 /* DO NOT CHANGE - maximum number of samples */