Skip to content

Commit 9e291b5

Browse files
committed
video: add more resolutions to GC2145
video: add more resolutions to GC2145 As I mentioned in issue #91968, It would be great if the camera drivers would support a larger number of resolutions. For example those resolutions of the displays that they wish to display an image on. Potentially in both landscape and portrait mode. So far I have added one the works in landscape mode for ILI948x and ST7796 displays as well as a QVGA in portrait mode, which should be good for LI9341 and some ST7789 displays. If this looks like a valid approach, I will also add the GIGA Display Adapter size. Probably need to add the duplicate items to the FORMAT_CAP list for YUYV mode. Note: the other than add the items to the list, I just added code to set resolution which computes the c_ratio/r_ratio chooses the smaller of the two to use. We may also remove most if not all of the items in the switch statement and simply use the default clause code for them. Signed-off-by: Kurt Eckhardt <[email protected]>
1 parent e92468c commit 9e291b5

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

drivers/video/gc2145.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,8 @@ static const struct video_format_cap fmts[] = {
796796
GC2145_VIDEO_FORMAT_CAP(RESOLUTION_QVGA_W, RESOLUTION_QVGA_H, VIDEO_PIX_FMT_RGB565),
797797
GC2145_VIDEO_FORMAT_CAP(RESOLUTION_VGA_W, RESOLUTION_VGA_H, VIDEO_PIX_FMT_RGB565),
798798
GC2145_VIDEO_FORMAT_CAP(RESOLUTION_UXGA_W, RESOLUTION_UXGA_H, VIDEO_PIX_FMT_RGB565),
799+
GC2145_VIDEO_FORMAT_CAP(480, 320, VIDEO_PIX_FMT_RGB565), /* ILI948x, ST7796 */
800+
GC2145_VIDEO_FORMAT_CAP(240, 320, VIDEO_PIX_FMT_RGB565), /* ILI9341, ST7785 port */
799801
GC2145_VIDEO_FORMAT_CAP(RESOLUTION_QVGA_W, RESOLUTION_QVGA_H, VIDEO_PIX_FMT_YUYV),
800802
GC2145_VIDEO_FORMAT_CAP(RESOLUTION_VGA_W, RESOLUTION_VGA_H, VIDEO_PIX_FMT_YUYV),
801803
GC2145_VIDEO_FORMAT_CAP(RESOLUTION_UXGA_W, RESOLUTION_UXGA_H, VIDEO_PIX_FMT_YUYV),
@@ -1036,8 +1038,19 @@ static int gc2145_set_resolution(const struct device *dev, uint32_t w, uint32_t
10361038
r_ratio = 1;
10371039
break;
10381040
default:
1039-
LOG_ERR("Unsupported resolution %d %d", w, h);
1040-
return -EIO;
1041+
if ((w > UXGA_HSIZE) || (h > UXGA_VSIZE)) {
1042+
LOG_ERR("Unsupported resolution %d %d", w, h);
1043+
return -EIO;
1044+
}
1045+
c_ratio = UXGA_HSIZE / w;
1046+
r_ratio = UXGA_VSIZE / h;
1047+
if (c_ratio < r_ratio) {
1048+
r_ratio = c_ratio;
1049+
} else {
1050+
c_ratio = r_ratio;
1051+
}
1052+
LOG_DBG("set resolution(%u %u): ratio: %u %u\n", w, h, c_ratio, r_ratio);
1053+
break;
10411054
};
10421055

10431056
/* Calculates the window boundaries to obtain the desired resolution */
@@ -1048,6 +1061,7 @@ static int gc2145_set_resolution(const struct device *dev, uint32_t w, uint32_t
10481061
win_x = ((UXGA_HSIZE - win_w) / 2);
10491062
win_y = ((UXGA_VSIZE - win_h) / 2);
10501063

1064+
LOG_DBG("xy: %u %u win: %u %u\n", x, y, win_w, win_h);
10511065
/* Set readout window first. */
10521066
ret = gc2145_set_window(dev, GC2145_REG_BLANK_WINDOW_BASE, win_x, win_y, win_w + 16,
10531067
win_h + 8);

0 commit comments

Comments
 (0)