am7xxx: introduce a new am7xxx_device_info type
authorAntonio Ospite <ospite@studenti.unina.it>
Thu, 1 Mar 2012 20:52:06 +0000 (21:52 +0100)
committerAntonio Ospite <ospite@studenti.unina.it>
Thu, 1 Mar 2012 20:52:06 +0000 (21:52 +0100)
This is in order to abstract the properties of an am7xxx device, for now
only native_width and native_height are supported.

src/am7xxx.c
src/am7xxx.h
src/picoproj.c

index 4ed7cf9..48704de 100644 (file)
@@ -652,10 +652,7 @@ int am7xxx_close_device(am7xxx_device *dev)
 }
 
 int am7xxx_get_device_info(am7xxx_device *dev,
-                          unsigned int *native_width,
-                          unsigned int *native_height,
-                          unsigned int *unknown0,
-                          unsigned int *unknown1)
+                          am7xxx_device_info *device_info)
 {
        int ret;
        struct am7xxx_header h = {
@@ -682,10 +679,13 @@ int am7xxx_get_device_info(am7xxx_device *dev,
        if (ret < 0)
                return ret;
 
-       *native_width = h.header_data.devinfo.native_width;
-       *native_height = h.header_data.devinfo.native_height;
-       *unknown0 = h.header_data.devinfo.unknown0;
-       *unknown1 = h.header_data.devinfo.unknown1;
+       device_info->native_width = h.header_data.devinfo.native_width;
+       device_info->native_height = h.header_data.devinfo.native_height;
+#if 0
+       /* No reason to expose these in the public API until we know what they mean */
+       device_info->unknown0 = h.header_data.devinfo.unknown0;
+       device_info->unknown1 = h.header_data.devinfo.unknown1;
+#endif
 
        return 0;
 }
index 13cb83d..7d821d6 100644 (file)
@@ -30,6 +30,11 @@ typedef struct _am7xxx_context am7xxx_context;
 struct _am7xxx_device;
 typedef struct _am7xxx_device am7xxx_device;
 
+typedef struct {
+       unsigned int native_width;
+       unsigned int native_height;
+} am7xxx_device_info;
+
 typedef enum {
        AM7XXX_LOG_FATAL   = 0,
        AM7XXX_LOG_ERROR   = 1,
@@ -65,10 +70,7 @@ int am7xxx_open_device(am7xxx_context *ctx,
 int am7xxx_close_device(am7xxx_device *dev);
 
 int am7xxx_get_device_info(am7xxx_device *dev,
-                          unsigned int *native_width,
-                          unsigned int *native_height,
-                          unsigned int *unknown0,
-                          unsigned int *unknown1);
+                          am7xxx_device_info *device_info);
 
 int am7xxx_send_image(am7xxx_device *dev,
                      am7xxx_image_format format,
index ec7bbb6..c3b199c 100644 (file)
@@ -59,10 +59,7 @@ int main(int argc, char *argv[])
        int height = 480;
        unsigned char *image;
        unsigned int size;
-       unsigned int native_width;
-       unsigned int native_height;
-       unsigned int unknown0;
-       unsigned int unknown1;
+       am7xxx_device_info device_info;
 
        while ((opt = getopt(argc, argv, "f:F:l:W:H:h")) != -1) {
                switch (opt) {
@@ -171,15 +168,14 @@ int main(int argc, char *argv[])
                goto cleanup;
        }
 
-       ret = am7xxx_get_device_info(dev, &native_width, &native_height, &unknown0, &unknown1);
+       ret = am7xxx_get_device_info(dev, &device_info);
        if (ret < 0) {
                perror("am7xxx_get_info");
                exit_code = EXIT_FAILURE;
                goto cleanup;
        }
-       printf("Native resolution: %dx%d\n", native_width, native_height);
-       printf("Unknown0: %d\n", unknown0);
-       printf("Unknown1: %d\n", unknown1);
+       printf("Native resolution: %dx%d\n",
+              device_info.native_width, device_info.native_height);
 
        ret = am7xxx_set_power_mode(dev, AM7XXX_POWER_LOW);
        if (ret < 0) {