Skip to content

Commit 3fdebd4

Browse files
committed
spresense: Add HDR camera support
1 parent d4aab42 commit 3fdebd4

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

ports/cxd56/common-hal/camera/Camera.c

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ typedef struct {
4747
uint16_t height;
4848
} image_size_t;
4949

50-
STATIC const image_size_t image_size_table[] = {
50+
STATIC const image_size_t isx012_image_size_table[] = {
5151
{ VIDEO_HSIZE_QVGA, VIDEO_VSIZE_QVGA },
5252
{ VIDEO_HSIZE_VGA, VIDEO_VSIZE_VGA },
5353
{ VIDEO_HSIZE_HD, VIDEO_VSIZE_HD },
@@ -57,12 +57,40 @@ STATIC const image_size_t image_size_table[] = {
5757
{ VIDEO_HSIZE_5M, VIDEO_VSIZE_5M },
5858
};
5959

60+
STATIC const image_size_t isx019_image_size_table[] = {
61+
{ VIDEO_HSIZE_QVGA, VIDEO_VSIZE_QVGA },
62+
{ VIDEO_HSIZE_VGA, VIDEO_VSIZE_VGA },
63+
{ VIDEO_HSIZE_HD, VIDEO_VSIZE_HD },
64+
{ VIDEO_HSIZE_QUADVGA, VIDEO_VSIZE_QUADVGA },
65+
};
66+
67+
static const char *get_imgsensor_name() {
68+
static struct v4l2_capability cap;
69+
70+
ioctl(camera_dev.fd, VIDIOC_QUERYCAP, (unsigned long)&cap);
71+
72+
return (const char *)cap.driver;
73+
}
74+
6075
static bool camera_check_width_and_height(uint16_t width, uint16_t height) {
61-
for (int i = 0; i < MP_ARRAY_SIZE(image_size_table); i++) {
62-
if (image_size_table[i].width == width && image_size_table[i].height == height) {
63-
return true;
76+
const char *sensor;
77+
78+
sensor = get_imgsensor_name();
79+
80+
if (strncmp(sensor, "ISX012", strlen("ISX012")) == 0) {
81+
for (int i = 0; i < MP_ARRAY_SIZE(isx012_image_size_table); i++) {
82+
if (isx012_image_size_table[i].width == width && isx012_image_size_table[i].height == height) {
83+
return true;
84+
}
85+
}
86+
} else if (strncmp(sensor, "ISX019", strlen("ISX019"))) {
87+
for (int i = 0; i < MP_ARRAY_SIZE(isx019_image_size_table); i++) {
88+
if (isx019_image_size_table[i].width == width && isx019_image_size_table[i].height == height) {
89+
return true;
90+
}
6491
}
6592
}
93+
6694
return false;
6795
}
6896

0 commit comments

Comments
 (0)