brintos

brintos / linux-shallow public Read only

0
0
Text · 1.4 KiB · dd8696d Raw
55 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/*3 * Copyright (C) 2021-2022 Digiteq Automotive4 *     author: Martin Tuma <martin.tuma@digiteqautomotive.com>5 */6 7#ifndef __MGB4_IO_H__8#define __MGB4_IO_H__9 10#include <linux/math64.h>11#include <media/v4l2-dev.h>12#include "mgb4_core.h"13 14/* Register access error indication */15#define MGB4_ERR_NO_REG        0xFFFFFFFE16/* Frame buffer addresses greater than 0xFFFFFFFA indicate HW errors */17#define MGB4_ERR_QUEUE_TIMEOUT 0xFFFFFFFD18#define MGB4_ERR_QUEUE_EMPTY   0xFFFFFFFC19#define MGB4_ERR_QUEUE_FULL    0xFFFFFFFB20 21#define MGB4_PERIOD(numerator, denominator) \22	((u32)div_u64((MGB4_HW_FREQ * (u64)(numerator)), (denominator)))23 24struct mgb4_frame_buffer {25	struct vb2_v4l2_buffer vb;26	struct list_head list;27};28 29static inline struct mgb4_frame_buffer *to_frame_buffer(struct vb2_v4l2_buffer *vbuf)30{31	return container_of(vbuf, struct mgb4_frame_buffer, vb);32}33 34static inline bool has_yuv_and_timeperframe(struct mgb4_regs *video)35{36	u32 status = mgb4_read_reg(video, 0xD0);37 38	return (status & (1U << 8));39}40 41#define has_yuv(video) has_yuv_and_timeperframe(video)42#define has_timeperframe(video) has_yuv_and_timeperframe(video)43 44static inline u32 pixel_size(struct v4l2_dv_timings *timings)45{46	struct v4l2_bt_timings *bt = &timings->bt;47 48	u32 height = bt->height + bt->vfrontporch + bt->vsync + bt->vbackporch;49	u32 width = bt->width + bt->hfrontporch + bt->hsync + bt->hbackporch;50 51	return width * height;52}53 54#endif55