linux/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 */
   2/*
   3 * Broadcom BM2835 V4L2 driver
   4 *
   5 * Copyright © 2013 Raspberry Pi (Trading) Ltd.
   6 *
   7 * Authors: Vincent Sanders <vincent.sanders@collabora.co.uk>
   8 *          Dave Stevenson <dsteve@broadcom.com>
   9 *          Simon Mellor <simellor@broadcom.com>
  10 *          Luke Diamand <luked@broadcom.com>
  11 *
  12 * MMAL interface to VCHIQ message passing
  13 */
  14
  15#ifndef MMAL_VCHIQ_H
  16#define MMAL_VCHIQ_H
  17
  18#include "mmal-msg-format.h"
  19
  20#define MAX_PORT_COUNT 4
  21
  22/* Maximum size of the format extradata. */
  23#define MMAL_FORMAT_EXTRADATA_MAX_SIZE 128
  24
  25struct vchiq_mmal_instance;
  26
  27enum vchiq_mmal_es_type {
  28        MMAL_ES_TYPE_UNKNOWN,     /**< Unknown elementary stream type */
  29        MMAL_ES_TYPE_CONTROL,     /**< Elementary stream of control commands */
  30        MMAL_ES_TYPE_AUDIO,       /**< Audio elementary stream */
  31        MMAL_ES_TYPE_VIDEO,       /**< Video elementary stream */
  32        MMAL_ES_TYPE_SUBPICTURE   /**< Sub-picture elementary stream */
  33};
  34
  35/* rectangle, used lots so it gets its own struct */
  36struct vchiq_mmal_rect {
  37        s32 x;
  38        s32 y;
  39        s32 width;
  40        s32 height;
  41};
  42
  43struct vchiq_mmal_port_buffer {
  44        unsigned int num; /* number of buffers */
  45        u32 size; /* size of buffers */
  46        u32 alignment; /* alignment of buffers */
  47};
  48
  49struct vchiq_mmal_port;
  50
  51typedef void (*vchiq_mmal_buffer_cb)(
  52                struct vchiq_mmal_instance  *instance,
  53                struct vchiq_mmal_port *port,
  54                int status, struct mmal_buffer *buffer,
  55                unsigned long length, u32 mmal_flags, s64 dts, s64 pts);
  56
  57struct vchiq_mmal_port {
  58        bool enabled;
  59        u32 handle;
  60        u32 type; /* port type, cached to use on port info set */
  61        u32 index; /* port index, cached to use on port info set */
  62
  63        /* component port belongs to, allows simple deref */
  64        struct vchiq_mmal_component *component;
  65
  66        struct vchiq_mmal_port *connected; /* port conencted to */
  67
  68        /* buffer info */
  69        struct vchiq_mmal_port_buffer minimum_buffer;
  70        struct vchiq_mmal_port_buffer recommended_buffer;
  71        struct vchiq_mmal_port_buffer current_buffer;
  72
  73        /* stream format */
  74        struct mmal_es_format_local format;
  75        /* elementary stream format */
  76        union mmal_es_specific_format es;
  77
  78        /* data buffers to fill */
  79        struct list_head buffers;
  80        /* lock to serialise adding and removing buffers from list */
  81        spinlock_t slock;
  82        /* count of how many buffer header refils have failed because
  83         * there was no buffer to satisfy them
  84         */
  85        int buffer_underflow;
  86        /* callback on buffer completion */
  87        vchiq_mmal_buffer_cb buffer_cb;
  88        /* callback context */
  89        void *cb_ctx;
  90};
  91
  92struct vchiq_mmal_component {
  93        bool enabled;
  94        u32 handle;  /* VideoCore handle for component */
  95        u32 inputs;  /* Number of input ports */
  96        u32 outputs; /* Number of output ports */
  97        u32 clocks;  /* Number of clock ports */
  98        struct vchiq_mmal_port control; /* control port */
  99        struct vchiq_mmal_port input[MAX_PORT_COUNT]; /* input ports */
 100        struct vchiq_mmal_port output[MAX_PORT_COUNT]; /* output ports */
 101        struct vchiq_mmal_port clock[MAX_PORT_COUNT]; /* clock ports */
 102};
 103
 104int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance);
 105int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance);
 106
 107/* Initialise a mmal component and its ports
 108 *
 109 */
 110int vchiq_mmal_component_init(
 111                struct vchiq_mmal_instance *instance,
 112                const char *name,
 113                struct vchiq_mmal_component **component_out);
 114
 115int vchiq_mmal_component_finalise(
 116                struct vchiq_mmal_instance *instance,
 117                struct vchiq_mmal_component *component);
 118
 119int vchiq_mmal_component_enable(
 120                struct vchiq_mmal_instance *instance,
 121                struct vchiq_mmal_component *component);
 122
 123int vchiq_mmal_component_disable(
 124                struct vchiq_mmal_instance *instance,
 125                struct vchiq_mmal_component *component);
 126
 127/* enable a mmal port
 128 *
 129 * enables a port and if a buffer callback provided enque buffer
 130 * headers as appropriate for the port.
 131 */
 132int vchiq_mmal_port_enable(
 133                struct vchiq_mmal_instance *instance,
 134                struct vchiq_mmal_port *port,
 135                vchiq_mmal_buffer_cb buffer_cb);
 136
 137/* disable a port
 138 *
 139 * disable a port will dequeue any pending buffers
 140 */
 141int vchiq_mmal_port_disable(struct vchiq_mmal_instance *instance,
 142                           struct vchiq_mmal_port *port);
 143
 144int vchiq_mmal_port_parameter_set(struct vchiq_mmal_instance *instance,
 145                                  struct vchiq_mmal_port *port,
 146                                  u32 parameter,
 147                                  void *value,
 148                                  u32 value_size);
 149
 150int vchiq_mmal_port_parameter_get(struct vchiq_mmal_instance *instance,
 151                                  struct vchiq_mmal_port *port,
 152                                  u32 parameter,
 153                                  void *value,
 154                                  u32 *value_size);
 155
 156int vchiq_mmal_port_set_format(struct vchiq_mmal_instance *instance,
 157                               struct vchiq_mmal_port *port);
 158
 159int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance,
 160                            struct vchiq_mmal_port *src,
 161                            struct vchiq_mmal_port *dst);
 162
 163int vchiq_mmal_version(struct vchiq_mmal_instance *instance,
 164                       u32 *major_out,
 165                       u32 *minor_out);
 166
 167int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance,
 168                             struct vchiq_mmal_port *port,
 169                             struct mmal_buffer *buf);
 170
 171#endif /* MMAL_VCHIQ_H */
 172