This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit 289ae14d09d8a894e93d6466bccfd7f71dd3bb1d
Author: yaojingwei <[email protected]>
AuthorDate: Fri Sep 18 22:50:27 2026 +0800

    system/nxcamera: use uint32_t for V4L2 control id
    
    In Linux, V4L2 control ids are 32 bits wide (struct v4l2_control.id and
    the query and menu control id fields are __u32), and NuttX is aligning
    include/sys/videoio.h with that. nxcamera passes &ctrl.id and &qctrl.id
    straight to nxcamera_find_ctrl_id(), which takes a uint16_t pointer, so
    with 32-bit id fields the set, get and query commands no longer build
    (incompatible pointer types, an error with -Werror).
    
    Widen nxcamera_ctrl_name_s.id and the nxcamera_find_ctrl_id()
    out-parameter to uint32_t, and look the id up into a local variable that
    is then assigned to the struct field. This builds with both the current
    16-bit and the new 32-bit id fields, so it does not depend on when the
    NuttX change is merged.
    
    Signed-off-by: yaojingwei <[email protected]>
---
 system/nxcamera/nxcamera_main.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/system/nxcamera/nxcamera_main.c b/system/nxcamera/nxcamera_main.c
index 07656115f..c3b760271 100644
--- a/system/nxcamera/nxcamera_main.c
+++ b/system/nxcamera/nxcamera_main.c
@@ -94,7 +94,7 @@ static int nxcamera_cmd_help(FAR struct nxcamera_s *pcam, FAR 
char *parg);
 struct nxcamera_ctrl_name_s
 {
   FAR const char *name;
-  uint16_t        id;
+  uint32_t        id;
 };
 
 static const struct nxcamera_ctrl_name_s g_ctrl_names[] =
@@ -396,7 +396,7 @@ static int nxcamera_cmd_output(FAR struct nxcamera_s *pcam, 
FAR char *parg)
  *
  ****************************************************************************/
 
-static int nxcamera_find_ctrl_id(FAR const char *name, FAR uint16_t *id)
+static int nxcamera_find_ctrl_id(FAR const char *name, FAR uint32_t *id)
 {
   int i;
 
@@ -424,6 +424,7 @@ static int nxcamera_cmd_set(FAR struct nxcamera_s *pcam, 
FAR char *parg)
 {
   struct v4l2_control ctrl;
   char                name[32];
+  uint32_t            id;
   int                 ret;
 
   if (!parg || sscanf(parg, "%31s %" SCNd32, name, &ctrl.value) < 2)
@@ -432,13 +433,14 @@ static int nxcamera_cmd_set(FAR struct nxcamera_s *pcam, 
FAR char *parg)
       return -EINVAL;
     }
 
-  ret = nxcamera_find_ctrl_id(name, &ctrl.id);
+  ret = nxcamera_find_ctrl_id(name, &id);
   if (ret < 0)
     {
       printf("Unknown control: %s\n", name);
       return ret;
     }
 
+  ctrl.id = id;
   ret = nxcamera_ioctl(pcam, VIDIOC_S_CTRL, (unsigned long)&ctrl);
   if (ret < 0)
     {
@@ -460,6 +462,7 @@ static int nxcamera_cmd_get(FAR struct nxcamera_s *pcam, 
FAR char *parg)
 {
   struct v4l2_control ctrl;
   char                name[32];
+  uint32_t            id;
   int                 ret;
 
   if (!parg || sscanf(parg, "%31s", name) < 1)
@@ -468,13 +471,14 @@ static int nxcamera_cmd_get(FAR struct nxcamera_s *pcam, 
FAR char *parg)
       return -EINVAL;
     }
 
-  ret = nxcamera_find_ctrl_id(name, &ctrl.id);
+  ret = nxcamera_find_ctrl_id(name, &id);
   if (ret < 0)
     {
       printf("Unknown control: %s\n", name);
       return ret;
     }
 
+  ctrl.id = id;
   ret = nxcamera_ioctl(pcam, VIDIOC_G_CTRL, (unsigned long)&ctrl);
   if (ret < 0)
     {
@@ -500,6 +504,7 @@ static int nxcamera_cmd_query(FAR struct nxcamera_s *pcam, 
FAR char *parg)
 {
   struct v4l2_queryctrl qctrl;
   char                  name[32];
+  uint32_t              id;
   int                   ret;
 
   if (!parg || sscanf(parg, "%31s", name) < 1)
@@ -508,13 +513,14 @@ static int nxcamera_cmd_query(FAR struct nxcamera_s 
*pcam, FAR char *parg)
       return -EINVAL;
     }
 
-  ret = nxcamera_find_ctrl_id(name, &qctrl.id);
+  ret = nxcamera_find_ctrl_id(name, &id);
   if (ret < 0)
     {
       printf("Unknown control: %s\n", name);
       return ret;
     }
 
+  qctrl.id = id;
   ret = nxcamera_ioctl(pcam, VIDIOC_QUERYCTRL, (unsigned long)&qctrl);
   if (ret < 0)
     {

Reply via email to