| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Media entity |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com> |
|---|
| 7 | 8 | * Sakari Ailus <sakari.ailus@iki.fi> |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 10 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 11 | | - * published by the Free Software Foundation. |
|---|
| 12 | | - * |
|---|
| 13 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 14 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 15 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 16 | | - * GNU General Public License for more details. |
|---|
| 17 | 9 | */ |
|---|
| 18 | 10 | |
|---|
| 19 | 11 | #ifndef _MEDIA_ENTITY_H |
|---|
| .. | .. |
|---|
| 25 | 17 | #include <linux/kernel.h> |
|---|
| 26 | 18 | #include <linux/list.h> |
|---|
| 27 | 19 | #include <linux/media.h> |
|---|
| 20 | +#include <linux/android_vendor.h> |
|---|
| 28 | 21 | |
|---|
| 29 | 22 | /* Enums used internally at the media controller to represent graphs */ |
|---|
| 30 | 23 | |
|---|
| .. | .. |
|---|
| 153 | 146 | struct media_link *reverse; |
|---|
| 154 | 147 | unsigned long flags; |
|---|
| 155 | 148 | bool is_backlink; |
|---|
| 149 | + ANDROID_VENDOR_DATA(1); |
|---|
| 150 | +}; |
|---|
| 151 | + |
|---|
| 152 | +/** |
|---|
| 153 | + * enum media_pad_signal_type - type of the signal inside a media pad |
|---|
| 154 | + * |
|---|
| 155 | + * @PAD_SIGNAL_DEFAULT: |
|---|
| 156 | + * Default signal. Use this when all inputs or all outputs are |
|---|
| 157 | + * uniquely identified by the pad number. |
|---|
| 158 | + * @PAD_SIGNAL_ANALOG: |
|---|
| 159 | + * The pad contains an analog signal. It can be Radio Frequency, |
|---|
| 160 | + * Intermediate Frequency, a baseband signal or sub-cariers. |
|---|
| 161 | + * Tuner inputs, IF-PLL demodulators, composite and s-video signals |
|---|
| 162 | + * should use it. |
|---|
| 163 | + * @PAD_SIGNAL_DV: |
|---|
| 164 | + * Contains a digital video signal, with can be a bitstream of samples |
|---|
| 165 | + * taken from an analog TV video source. On such case, it usually |
|---|
| 166 | + * contains the VBI data on it. |
|---|
| 167 | + * @PAD_SIGNAL_AUDIO: |
|---|
| 168 | + * Contains an Intermediate Frequency analog signal from an audio |
|---|
| 169 | + * sub-carrier or an audio bitstream. IF signals are provided by tuners |
|---|
| 170 | + * and consumed by audio AM/FM decoders. Bitstream audio is provided by |
|---|
| 171 | + * an audio decoder. |
|---|
| 172 | + */ |
|---|
| 173 | +enum media_pad_signal_type { |
|---|
| 174 | + PAD_SIGNAL_DEFAULT = 0, |
|---|
| 175 | + PAD_SIGNAL_ANALOG, |
|---|
| 176 | + PAD_SIGNAL_DV, |
|---|
| 177 | + PAD_SIGNAL_AUDIO, |
|---|
| 156 | 178 | }; |
|---|
| 157 | 179 | |
|---|
| 158 | 180 | /** |
|---|
| .. | .. |
|---|
| 161 | 183 | * @graph_obj: Embedded structure containing the media object common data |
|---|
| 162 | 184 | * @entity: Entity this pad belongs to |
|---|
| 163 | 185 | * @index: Pad index in the entity pads array, numbered from 0 to n |
|---|
| 186 | + * @sig_type: Type of the signal inside a media pad |
|---|
| 164 | 187 | * @flags: Pad flags, as defined in |
|---|
| 165 | 188 | * :ref:`include/uapi/linux/media.h <media_header>` |
|---|
| 166 | 189 | * (seek for ``MEDIA_PAD_FL_*``) |
|---|
| .. | .. |
|---|
| 169 | 192 | struct media_gobj graph_obj; /* must be first field in struct */ |
|---|
| 170 | 193 | struct media_entity *entity; |
|---|
| 171 | 194 | u16 index; |
|---|
| 195 | + enum media_pad_signal_type sig_type; |
|---|
| 172 | 196 | unsigned long flags; |
|---|
| 173 | 197 | }; |
|---|
| 174 | 198 | |
|---|
| .. | .. |
|---|
| 190 | 214 | * mutex held. |
|---|
| 191 | 215 | */ |
|---|
| 192 | 216 | struct media_entity_operations { |
|---|
| 193 | | - int (*get_fwnode_pad)(struct fwnode_endpoint *endpoint); |
|---|
| 217 | + int (*get_fwnode_pad)(struct media_entity *entity, |
|---|
| 218 | + struct fwnode_endpoint *endpoint); |
|---|
| 194 | 219 | int (*link_setup)(struct media_entity *entity, |
|---|
| 195 | 220 | const struct media_pad *local, |
|---|
| 196 | 221 | const struct media_pad *remote, u32 flags); |
|---|
| .. | .. |
|---|
| 641 | 666 | #endif |
|---|
| 642 | 667 | |
|---|
| 643 | 668 | /** |
|---|
| 669 | + * media_get_pad_index() - retrieves a pad index from an entity |
|---|
| 670 | + * |
|---|
| 671 | + * @entity: entity where the pads belong |
|---|
| 672 | + * @is_sink: true if the pad is a sink, false if it is a source |
|---|
| 673 | + * @sig_type: type of signal of the pad to be search |
|---|
| 674 | + * |
|---|
| 675 | + * This helper function finds the first pad index inside an entity that |
|---|
| 676 | + * satisfies both @is_sink and @sig_type conditions. |
|---|
| 677 | + * |
|---|
| 678 | + * Return: |
|---|
| 679 | + * |
|---|
| 680 | + * On success, return the pad number. If the pad was not found or the media |
|---|
| 681 | + * entity is a NULL pointer, return -EINVAL. |
|---|
| 682 | + */ |
|---|
| 683 | +int media_get_pad_index(struct media_entity *entity, bool is_sink, |
|---|
| 684 | + enum media_pad_signal_type sig_type); |
|---|
| 685 | + |
|---|
| 686 | +/** |
|---|
| 644 | 687 | * media_create_pad_link() - creates a link between two entities. |
|---|
| 645 | 688 | * |
|---|
| 646 | 689 | * @source: pointer to &media_entity of the source pad. |
|---|
| .. | .. |
|---|
| 762 | 805 | * @flags: the requested new link flags |
|---|
| 763 | 806 | * |
|---|
| 764 | 807 | * The only configurable property is the %MEDIA_LNK_FL_ENABLED link flag |
|---|
| 765 | | - * flag to enable/disable a link. Links marked with the |
|---|
| 808 | + * to enable/disable a link. Links marked with the |
|---|
| 766 | 809 | * %MEDIA_LNK_FL_IMMUTABLE link flag can not be enabled or disabled. |
|---|
| 767 | 810 | * |
|---|
| 768 | 811 | * When a link is enabled or disabled, the media framework calls the |
|---|
| .. | .. |
|---|
| 817 | 860 | struct media_pad *media_entity_remote_pad(const struct media_pad *pad); |
|---|
| 818 | 861 | |
|---|
| 819 | 862 | /** |
|---|
| 820 | | - * media_entity_get - Get a reference to the parent module |
|---|
| 821 | | - * |
|---|
| 822 | | - * @entity: The entity |
|---|
| 823 | | - * |
|---|
| 824 | | - * Get a reference to the parent media device module. |
|---|
| 825 | | - * |
|---|
| 826 | | - * The function will return immediately if @entity is %NULL. |
|---|
| 827 | | - * |
|---|
| 828 | | - * Return: returns a pointer to the entity on success or %NULL on failure. |
|---|
| 829 | | - */ |
|---|
| 830 | | -struct media_entity *media_entity_get(struct media_entity *entity); |
|---|
| 831 | | - |
|---|
| 832 | | -/** |
|---|
| 833 | 863 | * media_entity_get_fwnode_pad - Get pad number from fwnode |
|---|
| 834 | 864 | * |
|---|
| 835 | 865 | * @entity: The entity |
|---|
| .. | .. |
|---|
| 867 | 897 | * @graph: Media graph structure that will be used to walk the graph |
|---|
| 868 | 898 | */ |
|---|
| 869 | 899 | void media_graph_walk_cleanup(struct media_graph *graph); |
|---|
| 870 | | - |
|---|
| 871 | | -/** |
|---|
| 872 | | - * media_entity_put - Release the reference to the parent module |
|---|
| 873 | | - * |
|---|
| 874 | | - * @entity: The entity |
|---|
| 875 | | - * |
|---|
| 876 | | - * Release the reference count acquired by media_entity_get(). |
|---|
| 877 | | - * |
|---|
| 878 | | - * The function will return immediately if @entity is %NULL. |
|---|
| 879 | | - */ |
|---|
| 880 | | -void media_entity_put(struct media_entity *entity); |
|---|
| 881 | 900 | |
|---|
| 882 | 901 | /** |
|---|
| 883 | 902 | * media_graph_walk_start - Start walking the media graph at a |
|---|