1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
|
/*
* Copyright © 2018 NVIDIA Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef VIC_H
#define VIC_H
#include <stdio.h>
#include "host1x.h"
#define DXVAHD_FRAME_FORMAT_PROGRESSIVE 0
#define DXVAHD_FRAME_FORMAT_INTERLACED_TOP_FIELD_FIRST 1
#define DXVAHD_FRAME_FORMAT_INTERLACED_BOTTOM_FIELD_FIRST 2
#define DXVAHD_FRAME_FORMAT_TOP_FIELD 3
#define DXVAHD_FRAME_FORMAT_BOTTOM_FIELD 4
#define DXVAHD_FRAME_FORMAT_SUBPIC_PROGRESSIVE 5
#define DXVAHD_FRAME_FORMAT_SUBPIC_INTERLACED_TOP_FIELD_FIRST 6
#define DXVAHD_FRAME_FORMAT_SUBPIC_INTERLACED_BOTTOM_FIELD_FIRST 7
#define DXVAHD_FRAME_FORMAT_SUBPIC_TOP_FIELD 8
#define DXVAHD_FRAME_FORMAT_SUBPIC_BOTTOM_FIELD 9
#define DXVAHD_FRAME_FORMAT_TOP_FIELD_CHROMA_BOTTOM 10
#define DXVAHD_FRAME_FORMAT_BOTTOM_FIELD_CHROMA_TOP 11
#define DXVAHD_FRAME_FORMAT_SUBPIC_TOP_FIELD_CHROMA_BOTTOM 12
#define DXVAHD_FRAME_FORMAT_SUBPIC_BOTTOM_FIELD_CHROMA_TOP 13
#define DXVAHD_ALPHA_FILL_MODE_OPAQUE 0
#define DXVAHD_ALPHA_FILL_MODE_BACKGROUND 1
#define DXVAHD_ALPHA_FILL_MODE_DESTINATION 2
#define DXVAHD_ALPHA_FILL_MODE_SOURCE_STREAM 3
#define DXVAHD_ALPHA_FILL_MODE_COMPOSITED 4
#define DXVAHD_ALPHA_FILL_MODE_SOURCE_ALPHA 5
#define VIC_BLEND_SRCFACTC_K1 0
#define VIC_BLEND_SRCFACTC_K1_TIMES_DST 1
#define VIC_BLEND_SRCFACTC_NEG_K1_TIMES_DST 2
#define VIC_BLEND_SRCFACTC_K1_TIMES_SRC 3
#define VIC_BLEND_SRCFACTC_ZERO 4
#define VIC_BLEND_DSTFACTC_K1 0
#define VIC_BLEND_DSTFACTC_K2 1
#define VIC_BLEND_DSTFACTC_K1_TIMES_DST 2
#define VIC_BLEND_DSTFACTC_NEG_K1_TIMES_DST 3
#define VIC_BLEND_DSTFACTC_NEG_K1_TIMES_SRC 4
#define VIC_BLEND_DSTFACTC_ZERO 5
#define VIC_BLEND_DSTFACTC_ONE 6
#define VIC_BLEND_SRCFACTA_K1 0
#define VIC_BLEND_SRCFACTA_K2 1
#define VIC_BLEND_SRCFACTA_NEG_K1_TIMES_DST 2
#define VIC_BLEND_SRCFACTA_ZERO 3
#define VIC_BLEND_DSTFACTA_K2 0
#define VIC_BLEND_DSTFACTA_NEG_K1_TIMES_SRC 1
#define VIC_BLEND_DSTFACTA_ZERO 2
#define VIC_BLEND_DSTFACTA_ONE 3
#define VIC_BLK_KIND_PITCH 0
#define VIC_BLK_KIND_GENERIC_16Bx2 1
#define VIC_PIXEL_FORMAT_L8 1
#define VIC_PIXEL_FORMAT_R8 4
#define VIC_PIXEL_FORMAT_A8R8G8B8 32
#define VIC_PIXEL_FORMAT_R8G8B8A8 34
#define VIC_PIXEL_FORMAT_Y8_U8V8_N420 67
#define VIC_PIXEL_FORMAT_Y8_V8U8_N420 68
#define VIC_CACHE_WIDTH_16Bx16 0 /* BL16Bx2 */
#define VIC_CACHE_WIDTH_32Bx8 1 /* BL16Bx2 */
#define VIC_CACHE_WIDTH_64Bx4 2 /* BL16Bx2, PL */
#define VIC_CACHE_WIDTH_128Bx2 3 /* BL16Bx2, PL */
#define VIC_CACHE_WIDTH_256Bx1 4 /* PL */
struct vic_format_info {
unsigned int format;
unsigned int cpp;
};
#define VIC_UCLASS_INCR_SYNCPT 0x00
#define VIC_UCLASS_METHOD_OFFSET 0x10
#define VIC_UCLASS_METHOD_DATA 0x11
static inline void VIC_PUSH_METHOD(struct drm_tegra_pushbuf *pushbuf,
uint32_t **ptrp, uint32_t method,
uint32_t value)
{
*(*ptrp)++ = HOST1X_OPCODE_INCR(VIC_UCLASS_METHOD_OFFSET, 2);
*(*ptrp)++ = method >> 2;
*(*ptrp)++ = value;
}
static inline void VIC_PUSH_BUFFER(struct drm_tegra_pushbuf *pushbuf,
uint32_t **ptrp, uint32_t method,
struct drm_tegra_mapping *map,
unsigned long offset, unsigned long flags)
{
*(*ptrp)++ = HOST1X_OPCODE_INCR(VIC_UCLASS_METHOD_OFFSET, 2);
*(*ptrp)++ = method >> 2;
drm_tegra_pushbuf_relocate(pushbuf, ptrp, map, offset, 8, flags);
}
struct vic_image;
struct vic;
struct vic_ops {
int (*fill)(struct vic *vic, struct vic_image *output,
unsigned int left, unsigned int top,
unsigned int right, unsigned int bottom,
unsigned int alpha, unsigned red,
unsigned int green, unsigned int blue);
int (*blit)(struct vic *vic, struct vic_image *output,
struct vic_image *input);
int (*flip)(struct vic *vic, struct vic_image *output,
struct vic_image *input);
int (*execute)(struct vic *vic,
struct drm_tegra_pushbuf *pushbuf,
uint32_t **ptrp,
struct vic_image *output,
struct vic_image **inputs,
unsigned int num_inputs);
void (*free)(struct vic *vic);
};
struct vic {
struct drm_tegra *drm;
struct drm_tegra_channel *channel;
struct drm_tegra_syncpoint *syncpt;
const struct vic_ops *ops;
unsigned int version;
};
int vic_new(struct drm_tegra *drm, struct drm_tegra_channel *channel,
struct vic **vicp);
void vic_free(struct vic *vic);
int vic_clear(struct vic *vic, struct vic_image *output, unsigned int alpha,
unsigned int red, unsigned int green, unsigned int blue);
struct vic_image {
struct drm_tegra_bo *bo;
struct drm_tegra_mapping *map;
unsigned int width;
unsigned int stride;
unsigned int pitch;
unsigned int height;
unsigned int format;
unsigned int kind;
size_t align;
size_t size;
};
const struct vic_format_info *vic_format_get_info(unsigned int format);
int vic_image_new(struct vic *vic, unsigned int width, unsigned int height,
unsigned int format, unsigned int kind, uint32_t flags,
struct vic_image **imagep);
void vic_image_free(struct vic_image *image);
void vic_image_dump(struct vic_image *image, FILE *fp);
#endif
|