linux/drivers/media/platform/vsp1/vsp1_entity.h
<<
>>
Prefs
   1/*
   2 * vsp1_entity.h  --  R-Car VSP1 Base Entity
   3 *
   4 * Copyright (C) 2013-2014 Renesas Electronics Corporation
   5 *
   6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
   7 *
   8 * This program is free software; you can redistribute it and/or modify
   9 * it under the terms of the GNU General Public License as published by
  10 * the Free Software Foundation; either version 2 of the License, or
  11 * (at your option) any later version.
  12 */
  13#ifndef __VSP1_ENTITY_H__
  14#define __VSP1_ENTITY_H__
  15
  16#include <linux/list.h>
  17#include <linux/spinlock.h>
  18
  19#include <media/v4l2-subdev.h>
  20
  21struct vsp1_device;
  22struct vsp1_dl_list;
  23struct vsp1_pipeline;
  24
  25enum vsp1_entity_type {
  26        VSP1_ENTITY_BRU,
  27        VSP1_ENTITY_HSI,
  28        VSP1_ENTITY_HST,
  29        VSP1_ENTITY_LIF,
  30        VSP1_ENTITY_LUT,
  31        VSP1_ENTITY_RPF,
  32        VSP1_ENTITY_SRU,
  33        VSP1_ENTITY_UDS,
  34        VSP1_ENTITY_WPF,
  35};
  36
  37#define VSP1_ENTITY_MAX_INPUTS          5       /* For the BRU */
  38
  39/*
  40 * struct vsp1_route - Entity routing configuration
  41 * @type: Entity type this routing entry is associated with
  42 * @index: Entity index this routing entry is associated with
  43 * @reg: Output routing configuration register
  44 * @inputs: Target node value for each input
  45 *
  46 * Each $vsp1_route entry describes routing configuration for the entity
  47 * specified by the entry's @type and @index. @reg indicates the register that
  48 * holds output routing configuration for the entity, and the @inputs array
  49 * store the target node value for each input of the entity.
  50 */
  51struct vsp1_route {
  52        enum vsp1_entity_type type;
  53        unsigned int index;
  54        unsigned int reg;
  55        unsigned int inputs[VSP1_ENTITY_MAX_INPUTS];
  56};
  57
  58/**
  59 * struct vsp1_entity_operations - Entity operations
  60 * @destroy:    Destroy the entity.
  61 * @set_memory: Setup memory buffer access. This operation applies the settings
  62 *              stored in the rwpf mem field to the display list. Valid for RPF
  63 *              and WPF only.
  64 * @configure:  Setup the hardware based on the entity state (pipeline, formats,
  65 *              selection rectangles, ...)
  66 */
  67struct vsp1_entity_operations {
  68        void (*destroy)(struct vsp1_entity *);
  69        void (*set_memory)(struct vsp1_entity *, struct vsp1_dl_list *dl);
  70        void (*configure)(struct vsp1_entity *, struct vsp1_pipeline *,
  71                          struct vsp1_dl_list *);
  72};
  73
  74struct vsp1_entity {
  75        struct vsp1_device *vsp1;
  76
  77        const struct vsp1_entity_operations *ops;
  78
  79        enum vsp1_entity_type type;
  80        unsigned int index;
  81        const struct vsp1_route *route;
  82
  83        struct list_head list_dev;
  84        struct list_head list_pipe;
  85
  86        struct media_pad *pads;
  87        unsigned int source_pad;
  88
  89        struct media_entity *sink;
  90        unsigned int sink_pad;
  91
  92        struct v4l2_subdev subdev;
  93        struct v4l2_subdev_pad_config *config;
  94};
  95
  96static inline struct vsp1_entity *to_vsp1_entity(struct v4l2_subdev *subdev)
  97{
  98        return container_of(subdev, struct vsp1_entity, subdev);
  99}
 100
 101int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
 102                     const char *name, unsigned int num_pads,
 103                     const struct v4l2_subdev_ops *ops);
 104void vsp1_entity_destroy(struct vsp1_entity *entity);
 105
 106extern const struct v4l2_subdev_internal_ops vsp1_subdev_internal_ops;
 107
 108int vsp1_entity_link_setup(struct media_entity *entity,
 109                           const struct media_pad *local,
 110                           const struct media_pad *remote, u32 flags);
 111
 112struct v4l2_subdev_pad_config *
 113vsp1_entity_get_pad_config(struct vsp1_entity *entity,
 114                           struct v4l2_subdev_pad_config *cfg,
 115                           enum v4l2_subdev_format_whence which);
 116struct v4l2_mbus_framefmt *
 117vsp1_entity_get_pad_format(struct vsp1_entity *entity,
 118                           struct v4l2_subdev_pad_config *cfg,
 119                           unsigned int pad);
 120struct v4l2_rect *
 121vsp1_entity_get_pad_compose(struct vsp1_entity *entity,
 122                            struct v4l2_subdev_pad_config *cfg,
 123                            unsigned int pad);
 124int vsp1_entity_init_cfg(struct v4l2_subdev *subdev,
 125                         struct v4l2_subdev_pad_config *cfg);
 126
 127void vsp1_entity_route_setup(struct vsp1_entity *source,
 128                             struct vsp1_dl_list *dl);
 129
 130int vsp1_subdev_get_pad_format(struct v4l2_subdev *subdev,
 131                               struct v4l2_subdev_pad_config *cfg,
 132                               struct v4l2_subdev_format *fmt);
 133int vsp1_subdev_enum_mbus_code(struct v4l2_subdev *subdev,
 134                               struct v4l2_subdev_pad_config *cfg,
 135                               struct v4l2_subdev_mbus_code_enum *code,
 136                               const unsigned int *codes, unsigned int ncodes);
 137int vsp1_subdev_enum_frame_size(struct v4l2_subdev *subdev,
 138                                struct v4l2_subdev_pad_config *cfg,
 139                                struct v4l2_subdev_frame_size_enum *fse,
 140                                unsigned int min_w, unsigned int min_h,
 141                                unsigned int max_w, unsigned int max_h);
 142
 143#endif /* __VSP1_ENTITY_H__ */
 144