haltests: Update GetSupportedFormat function 34/323334/1 accepted/tizen_unified accepted/tizen_unified_x tizen accepted/tizen/unified/20250610.081753 accepted/tizen/unified/x/20250610.082521
authorJeongmo Yang <jm80.yang@samsung.com>
Fri, 25 Apr 2025 11:35:49 +0000 (20:35 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Fri, 25 Apr 2025 11:38:50 +0000 (20:38 +0900)
- Replace camera_device_info_list_s by camera_device_capability_list_s
 : If the supported resolution list can be different for each format,
   but, camera_device_info_list_s can not cover that case.

Change-Id: I224ac9bce2c0bf2e723af73d1cb5ad1927c137c4
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
tests/camera_hal_test.cpp

index a632e6708ff31316016e0f4ae65b43ff013d4d11..8aa55e8843329fe35b70f6ec8af63cd199c3e20d 100644 (file)
@@ -32,6 +32,7 @@ static int g_ret_release_extra_preview_buffer;
 static int g_ret_release_video_buffer;
 static void *g_hal_handle;
 static camera_device_info_list_s g_device_info_list;
+static camera_device_capability_list_s g_device_capability_list;
 static camera_format_s g_preview_format;
 static camera_format_s g_video_format;
 static GMutex g_msg_cb_lock;
@@ -197,7 +198,13 @@ class CameraHalTest : public testing::Test
 
                        ret = hal_camera_get_device_info_list(g_hal_handle, &g_device_info_list);
                        if (ret != CAMERA_ERROR_NONE) {
-                               cout << "get device list failed " << ret << endl;
+                               cout << "get device info list failed " << ret << endl;
+                               return;
+                       }
+
+                       ret = hal_camera_get_device_capability_list(g_hal_handle, &g_device_capability_list);
+                       if (ret != CAMERA_ERROR_NONE) {
+                               cout << "get device capability list failed " << ret << endl;
                                return;
                        }
 
@@ -212,37 +219,53 @@ class CameraHalTest : public testing::Test
                        }
                }
 
-               int GetSupportedFormat(int index)
+               int GetSupportedFormat(uint32_t device_index)
                {
-                       camera_device_info_s *d = NULL;
+                       camera_device_capability_s *capability = nullptr;
+                       camera_device_capability_format_s *capability_format = nullptr;
+                       camera_device_capability_resolution_s *capability_resolution = nullptr;
+
+                       if (device_index >= g_device_capability_list.device_count) {
+                               cout << "invalid device_index[" << device_index << "] vs device_count[" << g_device_capability_list.device_count << "]" << endl;
+                               return CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
+                       }
+
+                       capability = g_device_capability_list.capability[device_index];
+                       if (!capability || capability->format_count < 1 || !capability->format[0]) {
+                               cout << "no format for device[" << device_index << "]" << endl;
+                               return CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
+                       }
 
-                       if (g_device_info_list.count < 1) {
-                               cout << "no available camera device" << endl;
+                       capability_format = capability->format[0];
+                       if (capability_format->resolution_count < 1 || !capability_format->resolution[0]) {
+                               cout << "no resolution for format[0] of device[" << device_index << "]" << endl;
                                return CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
                        }
 
-                       d = &g_device_info_list.device_info[index];
+                       capability_resolution = capability_format->resolution[0];
+                       if (capability_resolution->fps_list.count < 1) {
+                               cout << "no FPS for format[0]:resolution[0] of device[" << device_index << "]" << endl;
+                               return CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
+                       }
 
-                       /* set preview format */
-                       g_preview_format.stream_format = d->format_list.formats[0];
-                       g_preview_format.stream_resolution.width = d->preview_list.resolutions[0].width;
-                       g_preview_format.stream_resolution.height = d->preview_list.resolutions[0].height;
-                       g_preview_format.stream_fps = d->preview_fps_list[0].fps[0];
+                       g_preview_format.stream_format = capability_format->pixel_format;
+                       g_preview_format.stream_resolution.width = capability_resolution->width;
+                       g_preview_format.stream_resolution.height = capability_resolution->height;
+                       g_preview_format.stream_fps = capability_resolution->fps_list.fps[capability_resolution->default_fps_index];
                        g_preview_format.stream_rotation = CAMERA_ROTATION_0;
-                       g_preview_format.capture_format = d->format_list.formats[0];
-                       g_preview_format.capture_resolution.width = d->capture_list.resolutions[0].width;
-                       g_preview_format.capture_resolution.height = d->capture_list.resolutions[0].height;
+                       g_preview_format.capture_format = capability_format->pixel_format;
+                       g_preview_format.capture_resolution.width = capability_resolution->width;
+                       g_preview_format.capture_resolution.height = capability_resolution->height;
                        g_preview_format.capture_quality = 95;
 
-                       /* set video format */
-                       g_video_format.stream_format = d->format_list.formats[0];
-                       g_video_format.stream_resolution.width = d->video_list.resolutions[0].width;
-                       g_video_format.stream_resolution.height = d->video_list.resolutions[0].height;
-                       g_video_format.stream_fps = d->video_fps_list[0].fps[0];;
+                       g_video_format.stream_format = capability_format->pixel_format;
+                       g_video_format.stream_resolution.width = capability_resolution->width;
+                       g_video_format.stream_resolution.height = capability_resolution->height;
+                       g_video_format.stream_fps = capability_resolution->fps_list.fps[capability_resolution->default_fps_index];
                        g_video_format.stream_rotation = CAMERA_ROTATION_0;
-                       g_video_format.capture_format = d->format_list.formats[0];
-                       g_video_format.capture_resolution.width = d->capture_list.resolutions[0].width;
-                       g_video_format.capture_resolution.height = d->capture_list.resolutions[0].height;
+                       g_video_format.capture_format = capability_format->pixel_format;
+                       g_video_format.capture_resolution.width = capability_resolution->width;
+                       g_video_format.capture_resolution.height = capability_resolution->height;
                        g_video_format.capture_quality = 95;
 
                        return CAMERA_ERROR_NONE;
@@ -579,7 +602,7 @@ TEST_F(CameraHalTest, GetPreviewStreamFormatN)
  */
 TEST_F(CameraHalTest, StartPreviewP)
 {
-       unsigned int i = 0;
+       uint32_t i = 0;
 
        CAMERA_SUPPORT_CHECK;