vibrator: tspdrv: clean up codes
Change-Id: I85ecec9fb01e21ea0cdf3fda1c43851c26c7f552
This commit is contained in:
committed by
Iliyan Malchev
parent
85c85ee651
commit
ace7135a0e
@@ -1,31 +1,28 @@
|
||||
/*
|
||||
** =========================================================================
|
||||
** File:
|
||||
** ImmVibeSPI.c
|
||||
**
|
||||
** Description:
|
||||
** 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.
|
||||
**
|
||||
** This file contains Original Code and/or Modifications of Original Code
|
||||
** as defined in and that are subject to the GNU Public License v2 -
|
||||
** (the 'License'). You may not use this file except in compliance with the
|
||||
** License. You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
** 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
|
||||
** EXPRESS OR IMPLIED, AND IMMERSION HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
** INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
** FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see
|
||||
** the License for the specific language governing rights and limitations
|
||||
** under the License.
|
||||
** =========================================================================
|
||||
*/
|
||||
* File: ImmVibeSPI.c
|
||||
*
|
||||
* Description:
|
||||
* 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.
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the GNU Public License v2 -
|
||||
* (the 'License'). You may not use this file except in compliance with the
|
||||
* License. You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 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
|
||||
* EXPRESS OR IMPLIED, AND IMMERSION HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
#include <linux/io.h>
|
||||
#include <linux/err.h>
|
||||
@@ -37,18 +34,6 @@
|
||||
#include <mach/msm_iomap.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;
|
||||
|
||||
/* 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_HALF (GP_CLK_N_DEFAULT >> 1)
|
||||
|
||||
#define MOTOR_AMP 120
|
||||
|
||||
|
||||
static struct gpiomux_setting vibrator_suspend_cfg = {
|
||||
.func = GPIOMUX_FUNC_GPIO,
|
||||
@@ -174,7 +157,6 @@ static int vibrator_power_set(int enable)
|
||||
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);
|
||||
|
||||
if(enable) {
|
||||
@@ -257,7 +239,7 @@ static void vibrator_ic_enable_set(int enable)
|
||||
/*
|
||||
** Called to disable amp (disable output force)
|
||||
*/
|
||||
IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_AmpDisable(VibeUInt8 nActuatorIndex)
|
||||
static VibeStatus ImmVibeSPI_ForceOut_AmpDisable(VibeUInt8 nActuatorIndex)
|
||||
{
|
||||
|
||||
if (g_bAmpEnabled) {
|
||||
@@ -276,7 +258,7 @@ IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_AmpDisable(VibeUInt8 nActuatorIndex
|
||||
/*
|
||||
** Called to enable amp (enable output force)
|
||||
*/
|
||||
IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_AmpEnable(VibeUInt8 nActuatorIndex)
|
||||
static VibeStatus ImmVibeSPI_ForceOut_AmpEnable(VibeUInt8 nActuatorIndex)
|
||||
{
|
||||
|
||||
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...
|
||||
*/
|
||||
IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_Initialize(void)
|
||||
static VibeStatus ImmVibeSPI_ForceOut_Initialize(void)
|
||||
{
|
||||
int rc;
|
||||
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...
|
||||
*/
|
||||
IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_Terminate(void)
|
||||
static VibeStatus ImmVibeSPI_ForceOut_Terminate(void)
|
||||
{
|
||||
|
||||
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
|
||||
*/
|
||||
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;
|
||||
|
||||
@@ -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)
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1,36 +1,33 @@
|
||||
/*
|
||||
** =========================================================================
|
||||
** File:
|
||||
** VibeOSKernelLinuxHRTime.c
|
||||
**
|
||||
** Description:
|
||||
** High Resolution Time helper functions for Linux.
|
||||
**
|
||||
** 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 -
|
||||
** (the 'License'). You may not use this file except in compliance with the
|
||||
** License. You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
** 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
|
||||
** EXPRESS OR IMPLIED, AND IMMERSION HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
** INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
** FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see
|
||||
** the License for the specific language governing rights and limitations
|
||||
** under the License.
|
||||
** =========================================================================
|
||||
*/
|
||||
* File: VibeOSKernelLinuxHRTime.c
|
||||
*
|
||||
* Description:
|
||||
* High Resolution Time helper functions for Linux.
|
||||
*
|
||||
* 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 -
|
||||
* (the 'License'). You may not use this file except in compliance with the
|
||||
* License. You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 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
|
||||
* EXPRESS OR IMPLIED, AND IMMERSION HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see
|
||||
* 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
|
||||
** of timer (such as HW timer or standard software timer) might be used to achieve
|
||||
** the 5ms required rate.
|
||||
*/
|
||||
* 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
|
||||
* the 5ms required rate.
|
||||
*/
|
||||
|
||||
#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"
|
||||
@@ -202,10 +199,11 @@ static void VibeOSKernelLinuxStartTimer(void)
|
||||
return;
|
||||
|
||||
/*
|
||||
** Use interruptible version of down to be safe
|
||||
** (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 */
|
||||
* Use interruptible version of down to be safe
|
||||
* (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
|
||||
*/
|
||||
res = down_interruptible(&g_hMutex);
|
||||
if (res != 0) {
|
||||
DbgOut((KERN_INFO "VibeOSKernelLinuxStartTimer: down_interruptible interrupted by a signal.\n"));
|
||||
|
||||
@@ -1,37 +1,34 @@
|
||||
/*
|
||||
** =========================================================================
|
||||
** File:
|
||||
** VibeOSKernelLinuxTime.c
|
||||
**
|
||||
** Description:
|
||||
** Time helper functions for Linux.
|
||||
**
|
||||
** 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 -
|
||||
** (the 'License'). You may not use this file except in compliance with the
|
||||
** License. You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
** 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
|
||||
** EXPRESS OR IMPLIED, AND IMMERSION HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
** INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
** FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see
|
||||
** the License for the specific language governing rights and limitations
|
||||
** under the License.
|
||||
** =========================================================================
|
||||
*/
|
||||
* File: VibeOSKernelLinuxTime.c
|
||||
*
|
||||
* Description:
|
||||
* Time helper functions for Linux.
|
||||
*
|
||||
* 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 -
|
||||
* (the 'License'). You may not use this file except in compliance with the
|
||||
* License. You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 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
|
||||
* EXPRESS OR IMPLIED, AND IMMERSION HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
#error "Please read the following statement"
|
||||
/*
|
||||
** 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
|
||||
** to achieve the 5ms required rate.
|
||||
*/
|
||||
* 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
|
||||
* to achieve the 5ms required rate.
|
||||
*/
|
||||
#error "End of statement"
|
||||
|
||||
#if (HZ != 1000)
|
||||
@@ -96,8 +93,10 @@ static int VibeOSKernelProcessData(void* data)
|
||||
((++g_nWatchdogCounter) > WATCHDOG_TIMEOUT)) {
|
||||
VibeInt8 cZero[1] = {0};
|
||||
|
||||
/* Nothing to play for all actuators,
|
||||
turn off the timer when we reach the watchdog tick count limit */
|
||||
/* Nothing to play for all actuators,
|
||||
* turn off the timer when we reach
|
||||
* the watchdog tick count limit
|
||||
*/
|
||||
ImmVibeSPI_ForceOut_SetSamples(i, 8, 1, cZero);
|
||||
ImmVibeSPI_ForceOut_AmpDisable(i);
|
||||
VibeOSKernelLinuxStopTimer();
|
||||
@@ -194,9 +193,10 @@ static void VibeOSKernelLinuxStartTimer(void)
|
||||
return;
|
||||
|
||||
/*
|
||||
** Use interruptible version of down to be safe
|
||||
** (try to not being stuck here if the mutex is not freed for any reason)
|
||||
*/
|
||||
* Use interruptible version of down to be safe
|
||||
* (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 */
|
||||
if (res != 0) {
|
||||
DbgOut((KERN_INFO "VibeOSKernelLinuxStartTimer: down_interruptible interrupted by a signal.\n"));
|
||||
@@ -211,11 +211,13 @@ static void VibeOSKernelLinuxStopTimer(void)
|
||||
g_bTimerStarted = false;
|
||||
|
||||
/*
|
||||
** Stop the timer.
|
||||
** Use del_timer vs. del_timer_sync
|
||||
** del_timer_sync may cause a Kernel "soft lockup" on multi-CPU platforms
|
||||
** as VibeOSKernelLinuxStopTimer is called from the timer tick handler.
|
||||
*/
|
||||
* Stop the timer.
|
||||
* Use del_timer vs. del_timer_sync
|
||||
* del_timer_sync may cause a Kernel "soft lockup"
|
||||
* on multi-CPU platforms
|
||||
* as VibeOSKernelLinuxStopTimer is called
|
||||
* from the timer tick handler.
|
||||
*/
|
||||
del_timer(&g_timerList);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,34 +1,27 @@
|
||||
/*
|
||||
** =========================================================================
|
||||
** File:
|
||||
** tspdrv.c
|
||||
**
|
||||
** Description:
|
||||
** TouchSense Kernel Module main entry-point.
|
||||
**
|
||||
** 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 -
|
||||
** (the 'License'). You may not use this file except in compliance with the
|
||||
** License. You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
** 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
|
||||
** EXPRESS OR IMPLIED, AND IMMERSION HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
** INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
** FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see
|
||||
** the License for the specific language governing rights and limitations
|
||||
** under the License.
|
||||
** =========================================================================
|
||||
*/
|
||||
|
||||
#ifndef __KERNEL__
|
||||
#define __KERNEL__
|
||||
#endif
|
||||
* File: tspdrv.c
|
||||
*
|
||||
* Description:
|
||||
* TouchSense Kernel Module main entry-point.
|
||||
*
|
||||
* 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 -
|
||||
* (the 'License'). You may not use this file except in compliance with the
|
||||
* License. You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 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
|
||||
* EXPRESS OR IMPLIED, AND IMMERSION HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
@@ -232,17 +225,17 @@ static int release(struct inode *inode, struct file *file)
|
||||
DbgOut((KERN_INFO "tspdrv: release.\n"));
|
||||
|
||||
/*
|
||||
** Reset force and stop timer when the driver is closed, to make sure
|
||||
** no dangling semaphore remains in the system, especially when the
|
||||
** driver is run outside of immvibed for testing purposes.
|
||||
*/
|
||||
* Reset force and stop timer when the driver is closed, to make sure
|
||||
* no dangling semaphore remains in the system, especially when the
|
||||
* driver is run outside of immvibed for testing purposes.
|
||||
*/
|
||||
VibeOSKernelLinuxStopTimer();
|
||||
|
||||
/*
|
||||
** Clear the variable used to store the magic number to prevent
|
||||
** unauthorized caller to write data. TouchSense service is the only
|
||||
** valid caller.
|
||||
*/
|
||||
* Clear the variable used to store the magic number to prevent
|
||||
* unauthorized caller to write data. TouchSense service is the only
|
||||
* valid caller.
|
||||
*/
|
||||
file->private_data = (void*)NULL;
|
||||
|
||||
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 */
|
||||
|
||||
/*
|
||||
** Prevent unauthorized caller to write data.
|
||||
** TouchSense service is the only valid caller.
|
||||
*/
|
||||
* 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;
|
||||
@@ -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) {
|
||||
/*
|
||||
** Index is about to go beyond the buffer size.
|
||||
** (Should never happen).
|
||||
*/
|
||||
* Index is about to go beyond the buffer size.
|
||||
* (Should never happen).
|
||||
*/
|
||||
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 */
|
||||
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) {
|
||||
g_SamplesBuffer[pInputBuffer->nActuatorIndex].nIndexPlayingBuffer = nIndexFreeBuffer;
|
||||
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) {
|
||||
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.
|
||||
*/
|
||||
/*
|
||||
* As we send one sample ahead of time, we need to finish
|
||||
* playing the last samplebefore 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 */
|
||||
/* 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]);
|
||||
for (i = 0; i < g_nForceLogIndex; i++) {
|
||||
printk(KERN_INFO "%d\t%d\n", g_nTime,
|
||||
g_nForceLog[i]);
|
||||
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:
|
||||
ImmVibeSPI_ForceOut_AmpEnable(arg);
|
||||
DbgRecorderReset((arg));
|
||||
DbgRecord((arg,";------- TSPDRV_ENABLE_AMP ---------\n"));
|
||||
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 */
|
||||
/* 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);
|
||||
}
|
||||
|
||||
@@ -1,30 +1,27 @@
|
||||
/*
|
||||
** =========================================================================
|
||||
** File:
|
||||
** tspdrv.h
|
||||
**
|
||||
** Description:
|
||||
** Constants and type definitions for the TouchSense Kernel Module.
|
||||
**
|
||||
** 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 -
|
||||
** (the 'License'). You may not use this file except in compliance with the
|
||||
** License. You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
** 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
|
||||
** EXPRESS OR IMPLIED, AND IMMERSION HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
** INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
** FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see
|
||||
** the License for the specific language governing rights and limitations
|
||||
** under the License.
|
||||
** =========================================================================
|
||||
*/
|
||||
* File: tspdrv.h
|
||||
*
|
||||
* Description:
|
||||
* Constants and type definitions for the TouchSense Kernel Module.
|
||||
*
|
||||
* 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 -
|
||||
* (the 'License'). You may not use this file except in compliance with the
|
||||
* License. You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 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
|
||||
* EXPRESS OR IMPLIED, AND IMMERSION HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
#ifndef _TSPDRV_H
|
||||
#define _TSPDRV_H
|
||||
@@ -41,7 +38,7 @@
|
||||
#define TSPDRV_ENABLE_AMP _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 3)
|
||||
#define TSPDRV_DISABLE_AMP _IO(TSPDRV_MAGIC_NUMBER & 0xFF, 4)
|
||||
#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 VIBE_OUTPUT_SAMPLE_SIZE 50 /* DO NOT CHANGE - maximum number of samples */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user