18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0+ */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * vsp1_dl.h  --  R-Car VSP1 Display List
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2015 Renesas Corporation
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci#ifndef __VSP1_DL_H__
108c2ecf20Sopenharmony_ci#define __VSP1_DL_H__
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/types.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_cistruct vsp1_device;
158c2ecf20Sopenharmony_cistruct vsp1_dl_body;
168c2ecf20Sopenharmony_cistruct vsp1_dl_body_pool;
178c2ecf20Sopenharmony_cistruct vsp1_dl_list;
188c2ecf20Sopenharmony_cistruct vsp1_dl_manager;
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci/* Keep these flags in sync with VSP1_DU_STATUS_* in include/media/vsp1.h. */
218c2ecf20Sopenharmony_ci#define VSP1_DL_FRAME_END_COMPLETED		BIT(0)
228c2ecf20Sopenharmony_ci#define VSP1_DL_FRAME_END_WRITEBACK		BIT(1)
238c2ecf20Sopenharmony_ci#define VSP1_DL_FRAME_END_INTERNAL		BIT(2)
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci/**
268c2ecf20Sopenharmony_ci * struct vsp1_dl_ext_cmd - Extended Display command
278c2ecf20Sopenharmony_ci * @pool: pool to which this command belongs
288c2ecf20Sopenharmony_ci * @free: entry in the pool of free commands list
298c2ecf20Sopenharmony_ci * @opcode: command type opcode
308c2ecf20Sopenharmony_ci * @flags: flags used by the command
318c2ecf20Sopenharmony_ci * @cmds: array of command bodies for this extended cmd
328c2ecf20Sopenharmony_ci * @num_cmds: quantity of commands in @cmds array
338c2ecf20Sopenharmony_ci * @cmd_dma: DMA address of the command body
348c2ecf20Sopenharmony_ci * @data: memory allocation for command-specific data
358c2ecf20Sopenharmony_ci * @data_dma: DMA address for command-specific data
368c2ecf20Sopenharmony_ci */
378c2ecf20Sopenharmony_cistruct vsp1_dl_ext_cmd {
388c2ecf20Sopenharmony_ci	struct vsp1_dl_cmd_pool *pool;
398c2ecf20Sopenharmony_ci	struct list_head free;
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci	u8 opcode;
428c2ecf20Sopenharmony_ci	u32 flags;
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci	struct vsp1_pre_ext_dl_body *cmds;
458c2ecf20Sopenharmony_ci	unsigned int num_cmds;
468c2ecf20Sopenharmony_ci	dma_addr_t cmd_dma;
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci	void *data;
498c2ecf20Sopenharmony_ci	dma_addr_t data_dma;
508c2ecf20Sopenharmony_ci};
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_civoid vsp1_dlm_setup(struct vsp1_device *vsp1);
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_cistruct vsp1_dl_manager *vsp1_dlm_create(struct vsp1_device *vsp1,
558c2ecf20Sopenharmony_ci					unsigned int index,
568c2ecf20Sopenharmony_ci					unsigned int prealloc);
578c2ecf20Sopenharmony_civoid vsp1_dlm_destroy(struct vsp1_dl_manager *dlm);
588c2ecf20Sopenharmony_civoid vsp1_dlm_reset(struct vsp1_dl_manager *dlm);
598c2ecf20Sopenharmony_ciunsigned int vsp1_dlm_irq_frame_end(struct vsp1_dl_manager *dlm);
608c2ecf20Sopenharmony_cistruct vsp1_dl_body *vsp1_dlm_dl_body_get(struct vsp1_dl_manager *dlm);
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_cistruct vsp1_dl_list *vsp1_dl_list_get(struct vsp1_dl_manager *dlm);
638c2ecf20Sopenharmony_civoid vsp1_dl_list_put(struct vsp1_dl_list *dl);
648c2ecf20Sopenharmony_cistruct vsp1_dl_body *vsp1_dl_list_get_body0(struct vsp1_dl_list *dl);
658c2ecf20Sopenharmony_cistruct vsp1_dl_ext_cmd *vsp1_dl_get_pre_cmd(struct vsp1_dl_list *dl);
668c2ecf20Sopenharmony_civoid vsp1_dl_list_commit(struct vsp1_dl_list *dl, unsigned int dl_flags);
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_cistruct vsp1_dl_body_pool *
698c2ecf20Sopenharmony_civsp1_dl_body_pool_create(struct vsp1_device *vsp1, unsigned int num_bodies,
708c2ecf20Sopenharmony_ci			 unsigned int num_entries, size_t extra_size);
718c2ecf20Sopenharmony_civoid vsp1_dl_body_pool_destroy(struct vsp1_dl_body_pool *pool);
728c2ecf20Sopenharmony_cistruct vsp1_dl_body *vsp1_dl_body_get(struct vsp1_dl_body_pool *pool);
738c2ecf20Sopenharmony_civoid vsp1_dl_body_put(struct vsp1_dl_body *dlb);
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_civoid vsp1_dl_body_write(struct vsp1_dl_body *dlb, u32 reg, u32 data);
768c2ecf20Sopenharmony_ciint vsp1_dl_list_add_body(struct vsp1_dl_list *dl, struct vsp1_dl_body *dlb);
778c2ecf20Sopenharmony_ciint vsp1_dl_list_add_chain(struct vsp1_dl_list *head, struct vsp1_dl_list *dl);
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci#endif /* __VSP1_DL_H__ */
80