File Index
Files and directories
Sign in
FILE

mgb4_io.h

File preview with syntax highlighting.

linux-6.19.14/drivers/media/pci/mgb4/mgb4_io.h C
 1/* SPDX-License-Identifier: GPL-2.0-only */
 2/*
 3 * Copyright (C) 2021-2022 Digiteq Automotive
 4 *     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        0xFFFFFFFE
16/* Frame buffer addresses greater than 0xFFFFFFFA indicate HW errors */
17#define MGB4_ERR_QUEUE_TIMEOUT 0xFFFFFFFD
18#define MGB4_ERR_QUEUE_EMPTY   0xFFFFFFFC
19#define MGB4_ERR_QUEUE_FULL    0xFFFFFFFB
20
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#endif
~/ Read-only file preview.