Commit b1b9b7be authored by Dmitry Osipenko's avatar Dmitry Osipenko Committed by Mauro Carvalho Chehab
Browse files

media: staging: media: tegra-vde: Manually pack UAPI structures



The __packed macro isn't available in userspace with the kernel headers.
Checkpatch asks to use the macro, which is unwanted in a case of a UAPI
header. There is no much benefit in a tight packing of the structures,
hence let's pack them manually to cleanup things a tad. Note that there
is no old-stable userspace that will suffer from this change, hence it's
fine to change the ABI. In a result also more space is reserved for a
possible future expansion of the UAPI as it was already shown that more
fields will be needed for a later SoC generations.

Suggested-by: default avatarThierry Reding <thierry.reding@gmail.com>
Signed-off-by: default avatarDmitry Osipenko <digetx@gmail.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 0f8cd165
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -795,7 +795,7 @@ static int tegra_vde_ioctl_decode_h264(struct tegra_vde *vde,
{
	struct device *dev = vde->miscdev.parent;
	struct tegra_vde_h264_decoder_ctx ctx;
	struct tegra_vde_h264_frame frames[17];
	struct tegra_vde_h264_frame *frames;
	struct tegra_vde_h264_frame __user *frames_user;
	struct video_frame *dpb_frames;
	struct dma_buf_attachment *bitstream_data_dmabuf_attachment;
@@ -830,11 +830,17 @@ static int tegra_vde_ioctl_decode_h264(struct tegra_vde *vde,
	if (ret)
		return ret;

	frames = kmalloc_array(ctx.dpb_frames_nb, sizeof(*frames), GFP_KERNEL);
	if (!frames) {
		ret = -ENOMEM;
		goto release_bitstream_dmabuf;
	}

	dpb_frames = kcalloc(ctx.dpb_frames_nb, sizeof(*dpb_frames),
			     GFP_KERNEL);
	if (!dpb_frames) {
		ret = -ENOMEM;
		goto release_bitstream_dmabuf;
		goto free_frames;
	}

	macroblocks_nb = ctx.pic_width_in_mbs * ctx.pic_height_in_mbs;
@@ -955,6 +961,9 @@ release_dpb_frames:
free_dpb_frames:
	kfree(dpb_frames);

free_frames:
	kfree(frames);

release_bitstream_dmabuf:
	tegra_vde_detach_and_put_dmabuf(bitstream_data_dmabuf_attachment,
					bitstream_sgt, DMA_TO_DEVICE);
+23 −21
Original line number Diff line number Diff line
@@ -21,40 +21,42 @@ struct tegra_vde_h264_frame {
	__u32 frame_num;
	__u32 flags;

	__u32 reserved;
} __attribute__((packed));
	// Must be zero'ed
	__u32 reserved[6];
};

struct tegra_vde_h264_decoder_ctx {
	__s32 bitstream_data_fd;
	__u32 bitstream_data_offset;

	__u64 dpb_frames_ptr;
	__u8  dpb_frames_nb;
	__u8  dpb_ref_frames_with_earlier_poc_nb;
	__u32 dpb_frames_nb;
	__u32 dpb_ref_frames_with_earlier_poc_nb;

	// SPS
	__u8  baseline_profile;
	__u8  level_idc;
	__u8  log2_max_pic_order_cnt_lsb;
	__u8  log2_max_frame_num;
	__u8  pic_order_cnt_type;
	__u8  direct_8x8_inference_flag;
	__u8  pic_width_in_mbs;
	__u8  pic_height_in_mbs;
	__u32 baseline_profile;
	__u32 level_idc;
	__u32 log2_max_pic_order_cnt_lsb;
	__u32 log2_max_frame_num;
	__u32 pic_order_cnt_type;
	__u32 direct_8x8_inference_flag;
	__u32 pic_width_in_mbs;
	__u32 pic_height_in_mbs;

	// PPS
	__u8  pic_init_qp;
	__u8  deblocking_filter_control_present_flag;
	__u8  constrained_intra_pred_flag;
	__u8  chroma_qp_index_offset;
	__u8  pic_order_present_flag;
	__u32 pic_init_qp;
	__u32 deblocking_filter_control_present_flag;
	__u32 constrained_intra_pred_flag;
	__u32 chroma_qp_index_offset;
	__u32 pic_order_present_flag;

	// Slice header
	__u8  num_ref_idx_l0_active_minus1;
	__u8  num_ref_idx_l1_active_minus1;
	__u32 num_ref_idx_l0_active_minus1;
	__u32 num_ref_idx_l1_active_minus1;

	__u32 reserved;
} __attribute__((packed));
	// Must be zero'ed
	__u32 reserved[11];
};

#define VDE_IOCTL_BASE			('v' + 0x20)