hi_v4l2.ko: decoder + encoder V4L2 stateful sobre HI_DRV_VDEC_*/HI_DRV_VENC_*. Decoder (/dev/video0): 6 codecs pixel-validados (H264/MPEG2/VP8/VP9/HEVC/MPEG-4), de-tile SW default-on (untile_plane, algoritmo do OMX vdec), capture kthread + back-pressure, CAPTURE vb2-vmalloc cached. ~37fps@1080p / 75fps@720p, v4l2-compliance 45/47. Encoder (/dev/video1): H264 (limite do VEDU), modelo desacoplado (capture kthread hi-venc-cap + feed-ahead + back-pressure + FIFO de src em voo), controles BITRATE/GOP_SIZE/H264_PROFILE/H264_LEVEL. ~42-52fps@1080p / 91fps@720p, dirigivel por gst v4l2h264enc / ffmpeg h264_v4l2m2m. Integracao in-tree no padrao dvb-hisi: Makefile inclui base.mak + MOD_NAME + lista de objetos; o parent drivers/msp/drv/Makefile pega o dir via objects +=. hi_v4l2 e obj-m (modulo) por depender de v4l2-mem2mem/videobuf2 (=m). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
72 lines
2.9 KiB
C
72 lines
2.9 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* V4L2 driver for Hisilicon (HiSTBLinux) video codec hardware.
|
|
* Format mapping: V4L2 fourcc <-> Hisilicon HI_UNF_VCODEC_TYPE_E.
|
|
*
|
|
* Primary target SoC: Hi3798Cv200.
|
|
*
|
|
* Dynamic capability discovery: HI_DRV_VDEC_GetCap() exists and is exported,
|
|
* but has no public prototype and returns a VDEC_CAP_S defined only in the
|
|
* internal vfmw.h. To keep this module self-contained it is wired behind
|
|
* HI_V4L2_USE_VDEC_GETCAP (off by default); when off we advertise the full
|
|
* real codec table (every entry maps to a real HI_UNF_VCODEC_TYPE_E). Turn it
|
|
* on once the prototype/header are confirmed against the SDK build tree.
|
|
*/
|
|
#ifndef __HI_V4L2_FMT_H__
|
|
#define __HI_V4L2_FMT_H__
|
|
|
|
#include <linux/videodev2.h>
|
|
#include "hi_drv_vdec.h" /* HI_UNF_VCODEC_TYPE_E, HI_DRV_PIX_FORMAT_E, ... */
|
|
|
|
/*
|
|
* Coded fourccs absent from the 4.4 UAPI but supported by the hardware.
|
|
* Values match upstream so userspace built against newer headers interops.
|
|
*/
|
|
#ifndef V4L2_PIX_FMT_HEVC
|
|
#define V4L2_PIX_FMT_HEVC v4l2_fourcc('H', 'E', 'V', 'C')
|
|
#endif
|
|
#ifndef V4L2_PIX_FMT_VP9
|
|
#define V4L2_PIX_FMT_VP9 v4l2_fourcc('V', 'P', '9', '0')
|
|
#endif
|
|
#ifndef V4L2_PIX_FMT_VC1_ANNEX_G
|
|
#define V4L2_PIX_FMT_VC1_ANNEX_G v4l2_fourcc('V', 'C', '1', 'G')
|
|
#endif
|
|
|
|
#define HI_V4L2_CODED (1 << 0) /* coded format the decoder accepts (OUTPUT) */
|
|
#define HI_V4L2_RAW (1 << 1) /* raw format (decoder CAPTURE / encoder OUTPUT) */
|
|
#define HI_V4L2_ENC (1 << 2) /* coded format the encoder produces (CAPTURE) */
|
|
|
|
struct hi_v4l2_fmt {
|
|
u32 fourcc; /* V4L2_PIX_FMT_* */
|
|
HI_UNF_VCODEC_TYPE_E vcodec; /* HI_UNF_VCODEC_TYPE_* (coded only) */
|
|
HI_DRV_PIX_FORMAT_E pixfmt; /* HI_DRV_PIX_FMT_* (raw only) */
|
|
u8 num_planes; /* contiguous planes */
|
|
u8 depth; /* bits per pixel (raw only) */
|
|
u32 flags; /* HI_V4L2_CODED / HI_V4L2_RAW */
|
|
};
|
|
|
|
const struct hi_v4l2_fmt *hi_v4l2_find_fmt(u32 fourcc, u32 flag);
|
|
const struct hi_v4l2_fmt *hi_v4l2_enum_fmt(unsigned int idx, u32 flag);
|
|
|
|
/*
|
|
* Narrow the advertised coded list to what this SoC accelerates. No-op unless
|
|
* HI_V4L2_USE_VDEC_GETCAP is defined. Returns the number of coded formats kept
|
|
* (or -1 when the feature is compiled out).
|
|
*/
|
|
int hi_v4l2_probe_hw_caps(void);
|
|
|
|
/*
|
|
* Narrow the advertised encode list to what the VENC actually accepts. @can_encode
|
|
* is called per encode-candidate format (a try-create against the VENC); the entry
|
|
* is kept iff it returns true. Run once at encoder probe. Returns the number kept.
|
|
*/
|
|
int hi_v4l2_probe_enc_caps(bool (*can_encode)(const struct hi_v4l2_fmt *fmt));
|
|
|
|
/* CAPTURE sizeimage for a decoded frame of the given raw fourcc. */
|
|
u32 hi_v4l2_raw_sizeimage(u32 fourcc, u32 width, u32 height, u32 *bytesperline);
|
|
|
|
/* Fill a stepwise VIDIOC_ENUM_FRAMESIZES reply (16-aligned, [16..max]). */
|
|
int hi_v4l2_fill_framesize(struct v4l2_frmsizeenum *fs, u32 maxw, u32 maxh);
|
|
|
|
#endif /* __HI_V4L2_FMT_H__ */
|