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:
yangguangcai
2024-06-18 21:42:18 +08:00
committed by Xiang Xiao
parent 5b1d910ec6
commit fd47add2a3
2 changed files with 41 additions and 0 deletions

View File

@@ -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
*/