From 43ea7e65e14991063f94ae61b69bb8fd97cf50cb Mon Sep 17 00:00:00 2001 From: jianglianfang Date: Fri, 21 Jul 2023 16:33:48 +0800 Subject: [PATCH] driver/fb: add fb_get_planeinfo and initialize local variable pinfo VELAPLATFO-11808 Change-Id: I32db03d52b778cc7dd1784adea0a432976fde6bf Signed-off-by: jianglianfang --- drivers/video/fb.c | 59 +++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/drivers/video/fb.c b/drivers/video/fb.c index cab15e4f77..532522931c 100644 --- a/drivers/video/fb.c +++ b/drivers/video/fb.c @@ -98,6 +98,9 @@ static int fb_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup); static int fb_get_panelinfo(FAR struct fb_chardev_s *fb, FAR struct fb_panelinfo_s *panelinfo); +static int fb_get_planeinfo(FAR struct fb_chardev_s *fb, + FAR struct fb_planeinfo_s *pinfo, + uint8_t display); /**************************************************************************** * Private Data @@ -429,9 +432,8 @@ static int fb_ioctl(FAR struct file *filep, int cmd, unsigned long arg) FAR struct fb_planeinfo_s *pinfo = (FAR struct fb_planeinfo_s *)((uintptr_t)arg); - DEBUGASSERT(pinfo != 0 && fb->vtable != NULL && - fb->vtable->getplaneinfo != NULL); - ret = fb->vtable->getplaneinfo(fb->vtable, fb->plane, pinfo); + DEBUGASSERT(pinfo != 0); + ret = fb_get_planeinfo(fb, pinfo, pinfo->display); } break; @@ -701,16 +703,14 @@ static int fb_ioctl(FAR struct file *filep, int cmd, unsigned long arg) (FAR struct fb_var_screeninfo *)((uintptr_t)arg); DEBUGASSERT(varinfo != 0 && fb->vtable != NULL && - fb->vtable->getvideoinfo != NULL && - fb->vtable->getplaneinfo != NULL); + fb->vtable->getvideoinfo != NULL); ret = fb->vtable->getvideoinfo(fb->vtable, &vinfo); if (ret < 0) { break; } - memset(&pinfo, 0, sizeof(pinfo)); - ret = fb->vtable->getplaneinfo(fb->vtable, fb->plane, &pinfo); + ret = fb_get_planeinfo(fb, &pinfo, 0); if (ret < 0) { break; @@ -795,16 +795,14 @@ static int fb_ioctl(FAR struct file *filep, int cmd, unsigned long arg) (FAR struct fb_fix_screeninfo *)((uintptr_t)arg); DEBUGASSERT(fixinfo != 0 && fb->vtable != NULL && - fb->vtable->getvideoinfo != NULL && - fb->vtable->getplaneinfo != NULL); + fb->vtable->getvideoinfo != NULL); ret = fb->vtable->getvideoinfo(fb->vtable, &vinfo); if (ret < 0) { break; } - memset(&pinfo, 0, sizeof(pinfo)); - ret = fb->vtable->getplaneinfo(fb->vtable, fb->plane, &pinfo); + ret = fb_get_planeinfo(fb, &pinfo, 0); if (ret < 0) { break; @@ -950,15 +948,9 @@ static int fb_get_panelinfo(FAR struct fb_chardev_s *fb, } #endif - DEBUGASSERT(fb->vtable != NULL); - DEBUGASSERT(fb->vtable->getplaneinfo != NULL); - memset(&pinfo, 0, sizeof(pinfo)); - - ret = fb->vtable->getplaneinfo(fb->vtable, fb->plane, &pinfo); - + ret = fb_get_planeinfo(fb, &pinfo, 0); if (ret < 0) { - gerr("ERROR: getplaneinfo() failed: %d\n", ret); return ret; } @@ -969,6 +961,33 @@ static int fb_get_panelinfo(FAR struct fb_chardev_s *fb, return OK; } +/**************************************************************************** + * Name: fb_get_planeinfo + ****************************************************************************/ + +static int fb_get_planeinfo(FAR struct fb_chardev_s *fb, + FAR struct fb_planeinfo_s *pinfo, + uint8_t display) +{ + int ret; + + DEBUGASSERT(fb->vtable != NULL); + DEBUGASSERT(fb->vtable->getplaneinfo != NULL); + + memset(pinfo, 0, sizeof(struct fb_planeinfo_s)); + pinfo->display = display; + + ret = fb->vtable->getplaneinfo(fb->vtable, fb->plane, pinfo); + + if (ret < 0) + { + gerr("ERROR: getplaneinfo() failed: %d\n", ret); + return ret; + } + + return OK; +} + /**************************************************************************** * Name: fb_do_pollnotify ****************************************************************************/ @@ -1110,11 +1129,9 @@ int fb_register(int display, int plane) /* Get plane info */ - DEBUGASSERT(fb->vtable->getplaneinfo != NULL); - ret = fb->vtable->getplaneinfo(fb->vtable, fb->plane, &pinfo); + ret = fb_get_planeinfo(fb, &pinfo, 0); if (ret < 0) { - gerr("ERROR: getplaneinfo() failed: %d\n", ret); goto errout_with_fb; }