forked from nuttx/nuttx-update
capture:add CAPIOC_ALL for ioctl.
When monitoring multiple capture channels, the `ioctl` function is called three times, leading to significant overhead mainly due to VFS and `nxmutex_lock/unlock`. Adding a new interface can save the overhead of two `ioctl` calls. Signed-off-by: yangguangcai <yangguangcai@xiaomi.com>
This commit is contained in:
parent
5b1d910ec6
commit
fd47add2a3
2 changed files with 41 additions and 0 deletions
|
@ -316,6 +316,39 @@ static int cap_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
}
|
||||
break;
|
||||
|
||||
/* CAPIOC_ALL - Get the pwm duty, pulse frequence, pwm edges, from
|
||||
* the capture.
|
||||
* Argument: A reference to struct cap_all_s.
|
||||
*/
|
||||
|
||||
case CAPIOC_ALL:
|
||||
{
|
||||
FAR struct cap_all_s *ptr =
|
||||
(FAR struct cap_all_s *)((uintptr_t)arg);
|
||||
DEBUGASSERT(lower->ops->getduty != NULL && ptr);
|
||||
DEBUGASSERT(lower->ops->getedges != NULL && ptr);
|
||||
DEBUGASSERT(lower->ops->getfreq != NULL && ptr);
|
||||
|
||||
ret = lower->ops->getduty(lower, &ptr->duty);
|
||||
if (ret < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
ret = lower->ops->getfreq(lower, &ptr->freq);
|
||||
if (ret < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
ret = lower->ops->getedges(lower, &ptr->edges);
|
||||
if (ret < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* Any unrecognized IOCTL commands might be platform-specific ioctl
|
||||
* commands
|
||||
*/
|
||||
|
|
|
@ -37,11 +37,19 @@
|
|||
#define CAPIOC_DUTYCYCLE _CAPIOC(1)
|
||||
#define CAPIOC_FREQUENCE _CAPIOC(2)
|
||||
#define CAPIOC_EDGES _CAPIOC(3)
|
||||
#define CAPIOC_ALL _CAPIOC(4)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
struct cap_all_s
|
||||
{
|
||||
uint32_t freq;
|
||||
uint32_t edges;
|
||||
uint8_t duty;
|
||||
};
|
||||
|
||||
/* This structure provides the "lower-half" driver operations available to
|
||||
* the "upper-half" driver.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue