Update to the latest media kernel API
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Tue, 21 Dec 2010 12:00:02 +0000 (13:00 +0100)
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Fri, 8 Apr 2011 08:32:49 +0000 (10:32 +0200)
The media kernel API has seen many changes during the review process,
update the media-ctl application accordingly.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
src/main.c
src/media.c
src/media.h

index 0bc6135..461dae1 100644 (file)
@@ -111,13 +111,13 @@ static const char *media_entity_type_to_string(unsigned type)
                __u32 type;
                const char *name;
        } types[] = {
                __u32 type;
                const char *name;
        } types[] = {
-               { MEDIA_ENTITY_TYPE_DEVNODE, "Node" },
-               { MEDIA_ENTITY_TYPE_V4L2_SUBDEV, "V4L2 subdev" },
+               { MEDIA_ENT_T_DEVNODE, "Node" },
+               { MEDIA_ENT_T_V4L2_SUBDEV, "V4L2 subdev" },
        };
 
        unsigned int i;
 
        };
 
        unsigned int i;
 
-       type &= MEDIA_ENTITY_TYPE_MASK;
+       type &= MEDIA_ENT_TYPE_MASK;
 
        for (i = 0; i < ARRAY_SIZE(types); i++) {
                if (types[i].type == type)
 
        for (i = 0; i < ARRAY_SIZE(types); i++) {
                if (types[i].type == type)
@@ -143,15 +143,15 @@ static const char *media_entity_subtype_to_string(unsigned type)
                "Lens",
        };
 
                "Lens",
        };
 
-       unsigned int subtype = type & MEDIA_ENTITY_SUBTYPE_MASK;
+       unsigned int subtype = type & MEDIA_ENT_SUBTYPE_MASK;
 
 
-       switch (type & MEDIA_ENTITY_TYPE_MASK) {
-       case MEDIA_ENTITY_TYPE_DEVNODE:
+       switch (type & MEDIA_ENT_TYPE_MASK) {
+       case MEDIA_ENT_T_DEVNODE:
                if (subtype >= ARRAY_SIZE(node_types))
                        subtype = 0;
                return node_types[subtype];
 
                if (subtype >= ARRAY_SIZE(node_types))
                        subtype = 0;
                return node_types[subtype];
 
-       case MEDIA_ENTITY_TYPE_V4L2_SUBDEV:
+       case MEDIA_ENT_T_V4L2_SUBDEV:
                if (subtype >= ARRAY_SIZE(subdev_types))
                        subtype = 0;
                return subdev_types[subtype];
                if (subtype >= ARRAY_SIZE(subdev_types))
                        subtype = 0;
                return subdev_types[subtype];
@@ -166,8 +166,8 @@ static const char *media_pad_type_to_string(unsigned flag)
                __u32 flag;
                const char *name;
        } flags[] = {
                __u32 flag;
                const char *name;
        } flags[] = {
-               { MEDIA_PAD_FLAG_INPUT, "Input" },
-               { MEDIA_PAD_FLAG_OUTPUT, "Output" },
+               { MEDIA_PAD_FL_SINK, "Input" },
+               { MEDIA_PAD_FL_SOURCE, "Output" },
        };
 
        unsigned int i;
        };
 
        unsigned int i;
@@ -192,17 +192,17 @@ static void media_print_topology_dot(struct media_device *media)
                unsigned int npads;
 
                switch (media_entity_type(entity)) {
                unsigned int npads;
 
                switch (media_entity_type(entity)) {
-               case MEDIA_ENTITY_TYPE_DEVNODE:
+               case MEDIA_ENT_T_DEVNODE:
                        printf("\tn%08x [label=\"%s\\n%s\", shape=box, style=filled, "
                               "fillcolor=yellow]\n",
                               entity->info.id, entity->info.name, entity->devname);
                        break;
 
                        printf("\tn%08x [label=\"%s\\n%s\", shape=box, style=filled, "
                               "fillcolor=yellow]\n",
                               entity->info.id, entity->info.name, entity->devname);
                        break;
 
-               case MEDIA_ENTITY_TYPE_V4L2_SUBDEV:
+               case MEDIA_ENT_T_V4L2_SUBDEV:
                        printf("\tn%08x [label=\"{{", entity->info.id);
 
                        for (j = 0, npads = 0; j < entity->info.pads; ++j) {
                        printf("\tn%08x [label=\"{{", entity->info.id);
 
                        for (j = 0, npads = 0; j < entity->info.pads; ++j) {
-                               if (!(entity->pads[j].flags & MEDIA_PAD_FLAG_INPUT))
+                               if (!(entity->pads[j].flags & MEDIA_PAD_FL_SINK))
                                        continue;
 
                                printf("%s<port%u> %u", npads ? " | " : "", j, j);
                                        continue;
 
                                printf("%s<port%u> %u", npads ? " | " : "", j, j);
@@ -215,7 +215,7 @@ static void media_print_topology_dot(struct media_device *media)
                        printf(" | {");
 
                        for (j = 0, npads = 0; j < entity->info.pads; ++j) {
                        printf(" | {");
 
                        for (j = 0, npads = 0; j < entity->info.pads; ++j) {
-                               if (!(entity->pads[j].flags & MEDIA_PAD_FLAG_OUTPUT))
+                               if (!(entity->pads[j].flags & MEDIA_PAD_FL_SOURCE))
                                        continue;
 
                                printf("%s<port%u> %u", npads ? " | " : "", j, j);
                                        continue;
 
                                printf("%s<port%u> %u", npads ? " | " : "", j, j);
@@ -236,16 +236,16 @@ static void media_print_topology_dot(struct media_device *media)
                                continue;
 
                        printf("\tn%08x", link->source->entity->info.id);
                                continue;
 
                        printf("\tn%08x", link->source->entity->info.id);
-                       if (media_entity_type(link->source->entity) == MEDIA_ENTITY_TYPE_V4L2_SUBDEV)
+                       if (media_entity_type(link->source->entity) == MEDIA_ENT_T_V4L2_SUBDEV)
                                printf(":port%u", link->source->index);
                        printf(" -> ");
                        printf("n%08x", link->sink->entity->info.id);
                                printf(":port%u", link->source->index);
                        printf(" -> ");
                        printf("n%08x", link->sink->entity->info.id);
-                       if (media_entity_type(link->sink->entity) == MEDIA_ENTITY_TYPE_V4L2_SUBDEV)
+                       if (media_entity_type(link->sink->entity) == MEDIA_ENT_T_V4L2_SUBDEV)
                                printf(":port%u", link->sink->index);
 
                                printf(":port%u", link->sink->index);
 
-                       if (link->flags & MEDIA_LINK_FLAG_IMMUTABLE)
+                       if (link->flags & MEDIA_LNK_FL_IMMUTABLE)
                                printf(" [style=bold]");
                                printf(" [style=bold]");
-                       else if (!(link->flags & MEDIA_LINK_FLAG_ENABLED))
+                       else if (!(link->flags & MEDIA_LNK_FL_ENABLED))
                                printf(" [style=dashed]");
                        printf("\n");
                }
                                printf(" [style=dashed]");
                        printf("\n");
                }
@@ -279,7 +279,7 @@ static void media_print_topology_text(struct media_device *media)
 
                        printf("\tpad%u: %s ", j, media_pad_type_to_string(pad->flags));
 
 
                        printf("\tpad%u: %s ", j, media_pad_type_to_string(pad->flags));
 
-                       if (media_entity_type(entity) == MEDIA_ENTITY_TYPE_V4L2_SUBDEV)
+                       if (media_entity_type(entity) == MEDIA_ENT_T_V4L2_SUBDEV)
                                v4l2_subdev_print_format(entity, j, V4L2_SUBDEV_FORMAT_ACTIVE);
 
                        printf("\n");
                                v4l2_subdev_print_format(entity, j, V4L2_SUBDEV_FORMAT_ACTIVE);
 
                        printf("\n");
@@ -298,9 +298,9 @@ static void media_print_topology_text(struct media_device *media)
                                else
                                        continue;
 
                                else
                                        continue;
 
-                               if (link->flags & MEDIA_LINK_FLAG_IMMUTABLE)
+                               if (link->flags & MEDIA_LNK_FL_IMMUTABLE)
                                        printf("IMMUTABLE,");
                                        printf("IMMUTABLE,");
-                               if (link->flags & MEDIA_LINK_FLAG_ENABLED)
+                               if (link->flags & MEDIA_LNK_FL_ENABLED)
                                        printf("ACTIVE");
 
                                printf("]\n");
                                        printf("ACTIVE");
 
                                printf("]\n");
@@ -670,7 +670,7 @@ static int setup_format(struct media_device *media, const char *p, char **endp)
                return -EINVAL;
        }
 
                return -EINVAL;
        }
 
-       if (pad->flags & MEDIA_PAD_FLAG_OUTPUT) {
+       if (pad->flags & MEDIA_PAD_FL_SOURCE) {
                ret = set_crop(pad, &crop);
                if (ret < 0)
                        return ret;
                ret = set_crop(pad, &crop);
                if (ret < 0)
                        return ret;
@@ -680,7 +680,7 @@ static int setup_format(struct media_device *media, const char *p, char **endp)
        if (ret < 0)
                return ret;
 
        if (ret < 0)
                return ret;
 
-       if (pad->flags & MEDIA_PAD_FLAG_INPUT) {
+       if (pad->flags & MEDIA_PAD_FL_SINK) {
                ret = set_crop(pad, &crop);
                if (ret < 0)
                        return ret;
                ret = set_crop(pad, &crop);
                if (ret < 0)
                        return ret;
@@ -694,16 +694,16 @@ static int setup_format(struct media_device *media, const char *p, char **endp)
        /* If the pad is an output pad, automatically set the same format on
         * the remote subdev input pads, if any.
         */
        /* If the pad is an output pad, automatically set the same format on
         * the remote subdev input pads, if any.
         */
-       if (pad->flags & MEDIA_PAD_FLAG_OUTPUT) {
+       if (pad->flags & MEDIA_PAD_FL_SOURCE) {
                for (i = 0; i < pad->entity->num_links; ++i) {
                        struct media_link *link = &pad->entity->links[i];
                        struct v4l2_mbus_framefmt remote_format;
 
                for (i = 0; i < pad->entity->num_links; ++i) {
                        struct media_link *link = &pad->entity->links[i];
                        struct v4l2_mbus_framefmt remote_format;
 
-                       if (!(link->flags & MEDIA_LINK_FLAG_ENABLED))
+                       if (!(link->flags & MEDIA_LNK_FL_ENABLED))
                                continue;
 
                        if (link->source == pad &&
                                continue;
 
                        if (link->source == pad &&
-                           link->sink->entity->info.type == MEDIA_ENTITY_TYPE_V4L2_SUBDEV) {
+                           link->sink->entity->info.type == MEDIA_ENT_T_V4L2_SUBDEV) {
                                remote_format = format;
                                set_format(link->sink, &remote_format);
                        }
                                remote_format = format;
                                set_format(link->sink, &remote_format);
                        }
index 512330a..7e4174d 100644 (file)
@@ -38,13 +38,13 @@ struct media_pad *media_entity_remote_source(struct media_pad *pad)
 {
        unsigned int i;
 
 {
        unsigned int i;
 
-       if (!(pad->flags & MEDIA_PAD_FLAG_INPUT))
+       if (!(pad->flags & MEDIA_PAD_FL_SINK))
                return NULL;
 
        for (i = 0; i < pad->entity->num_links; ++i) {
                struct media_link *link = &pad->entity->links[i];
 
                return NULL;
 
        for (i = 0; i < pad->entity->num_links; ++i) {
                struct media_link *link = &pad->entity->links[i];
 
-               if (!(link->flags & MEDIA_LINK_FLAG_ENABLED))
+               if (!(link->flags & MEDIA_LNK_FL_ENABLED))
                        continue;
 
                if (link->sink == pad)
                        continue;
 
                if (link->sink == pad)
@@ -112,14 +112,14 @@ int media_setup_link(struct media_device *media,
        /* source pad */
        ulink.source.entity = source->entity->info.id;
        ulink.source.index = source->index;
        /* source pad */
        ulink.source.entity = source->entity->info.id;
        ulink.source.index = source->index;
-       ulink.source.flags = MEDIA_PAD_FLAG_OUTPUT;
+       ulink.source.flags = MEDIA_PAD_FL_SOURCE;
 
        /* sink pad */
        ulink.sink.entity = sink->entity->info.id;
        ulink.sink.index = sink->index;
 
        /* sink pad */
        ulink.sink.entity = sink->entity->info.id;
        ulink.sink.index = sink->index;
-       ulink.sink.flags = MEDIA_PAD_FLAG_INPUT;
+       ulink.sink.flags = MEDIA_PAD_FL_SINK;
 
 
-       ulink.flags = flags | (link->flags & MEDIA_LINK_FLAG_IMMUTABLE);
+       ulink.flags = flags | (link->flags & MEDIA_LNK_FL_IMMUTABLE);
 
        ret = ioctl(media->fd, MEDIA_IOC_SETUP_LINK, &ulink);
        if (ret < 0) {
 
        ret = ioctl(media->fd, MEDIA_IOC_SETUP_LINK, &ulink);
        if (ret < 0) {
@@ -144,12 +144,12 @@ int media_reset_links(struct media_device *media)
                for (j = 0; j < entity->num_links; j++) {
                        struct media_link *link = &entity->links[j];
 
                for (j = 0; j < entity->num_links; j++) {
                        struct media_link *link = &entity->links[j];
 
-                       if (link->flags & MEDIA_LINK_FLAG_IMMUTABLE ||
+                       if (link->flags & MEDIA_LNK_FL_IMMUTABLE ||
                            link->source->entity != entity)
                                continue;
 
                        ret = media_setup_link(media, link->source, link->sink,
                            link->source->entity != entity)
                                continue;
 
                        ret = media_setup_link(media, link->source, link->sink,
-                                              link->flags & ~MEDIA_LINK_FLAG_ENABLED);
+                                              link->flags & ~MEDIA_LNK_FL_ENABLED);
                        if (ret < 0)
                                return ret;
                }
                        if (ret < 0)
                                return ret;
                }
@@ -264,7 +264,7 @@ static int media_enum_entities(struct media_device *media)
                entity = &media->entities[media->entities_count];
                memset(entity, 0, sizeof(*entity));
                entity->fd = -1;
                entity = &media->entities[media->entities_count];
                memset(entity, 0, sizeof(*entity));
                entity->fd = -1;
-               entity->info.id = id | MEDIA_ENTITY_ID_FLAG_NEXT;
+               entity->info.id = id | MEDIA_ENT_ID_FLAG_NEXT;
 
                ret = ioctl(media->fd, MEDIA_IOC_ENUM_ENTITIES, &entity->info);
                if (ret < 0) {
 
                ret = ioctl(media->fd, MEDIA_IOC_ENUM_ENTITIES, &entity->info);
                if (ret < 0) {
@@ -287,8 +287,8 @@ static int media_enum_entities(struct media_device *media)
                media->entities_count++;
 
                /* Find the corresponding device name. */
                media->entities_count++;
 
                /* Find the corresponding device name. */
-               if (media_entity_type(entity) != MEDIA_ENTITY_TYPE_DEVNODE &&
-                   media_entity_type(entity) != MEDIA_ENTITY_TYPE_V4L2_SUBDEV)
+               if (media_entity_type(entity) != MEDIA_ENT_T_DEVNODE &&
+                   media_entity_type(entity) != MEDIA_ENT_T_V4L2_SUBDEV)
                        continue;
 
                sprintf(sysname, "/sys/dev/char/%u:%u", entity->info.v4l.major,
                        continue;
 
                sprintf(sysname, "/sys/dev/char/%u:%u", entity->info.v4l.major,
index 80cf976..b91a2ac 100644 (file)
@@ -100,7 +100,7 @@ struct media_pad *media_entity_remote_source(struct media_pad *pad);
  */
 static inline unsigned int media_entity_type(struct media_entity *entity)
 {
  */
 static inline unsigned int media_entity_type(struct media_entity *entity)
 {
-       return entity->info.type & MEDIA_ENTITY_TYPE_MASK;
+       return entity->info.type & MEDIA_ENT_TYPE_MASK;
 }
 
 /**
 }
 
 /**