18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  PS3 GPU declarations.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  Copyright 2009 Sony Corporation
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef _ASM_POWERPC_PS3GPU_H
98c2ecf20Sopenharmony_ci#define _ASM_POWERPC_PS3GPU_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <linux/mutex.h>
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include <asm/lv1call.h>
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC	0x101
178c2ecf20Sopenharmony_ci#define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP	0x102
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#define L1GPU_CONTEXT_ATTRIBUTE_FB_SETUP	0x600
208c2ecf20Sopenharmony_ci#define L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT		0x601
218c2ecf20Sopenharmony_ci#define L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT_SYNC	0x602
228c2ecf20Sopenharmony_ci#define L1GPU_CONTEXT_ATTRIBUTE_FB_CLOSE	0x603
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#define L1GPU_FB_BLIT_WAIT_FOR_COMPLETION	(1ULL << 32)
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#define L1GPU_DISPLAY_SYNC_HSYNC		1
278c2ecf20Sopenharmony_ci#define L1GPU_DISPLAY_SYNC_VSYNC		2
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci/* mutex synchronizing GPU accesses and video mode changes */
318c2ecf20Sopenharmony_ciextern struct mutex ps3_gpu_mutex;
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_cistatic inline int lv1_gpu_display_sync(u64 context_handle, u64 head,
358c2ecf20Sopenharmony_ci				       u64 ddr_offset)
368c2ecf20Sopenharmony_ci{
378c2ecf20Sopenharmony_ci	return lv1_gpu_context_attribute(context_handle,
388c2ecf20Sopenharmony_ci					 L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC,
398c2ecf20Sopenharmony_ci					 head, ddr_offset, 0, 0);
408c2ecf20Sopenharmony_ci}
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_cistatic inline int lv1_gpu_display_flip(u64 context_handle, u64 head,
438c2ecf20Sopenharmony_ci				       u64 ddr_offset)
448c2ecf20Sopenharmony_ci{
458c2ecf20Sopenharmony_ci	return lv1_gpu_context_attribute(context_handle,
468c2ecf20Sopenharmony_ci					 L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP,
478c2ecf20Sopenharmony_ci					 head, ddr_offset, 0, 0);
488c2ecf20Sopenharmony_ci}
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_cistatic inline int lv1_gpu_fb_setup(u64 context_handle, u64 xdr_lpar,
518c2ecf20Sopenharmony_ci				   u64 xdr_size, u64 ioif_offset)
528c2ecf20Sopenharmony_ci{
538c2ecf20Sopenharmony_ci	return lv1_gpu_context_attribute(context_handle,
548c2ecf20Sopenharmony_ci					 L1GPU_CONTEXT_ATTRIBUTE_FB_SETUP,
558c2ecf20Sopenharmony_ci					 xdr_lpar, xdr_size, ioif_offset, 0);
568c2ecf20Sopenharmony_ci}
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_cistatic inline int lv1_gpu_fb_blit(u64 context_handle, u64 ddr_offset,
598c2ecf20Sopenharmony_ci				  u64 ioif_offset, u64 sync_width, u64 pitch)
608c2ecf20Sopenharmony_ci{
618c2ecf20Sopenharmony_ci	return lv1_gpu_context_attribute(context_handle,
628c2ecf20Sopenharmony_ci					 L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT,
638c2ecf20Sopenharmony_ci					 ddr_offset, ioif_offset, sync_width,
648c2ecf20Sopenharmony_ci					 pitch);
658c2ecf20Sopenharmony_ci}
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_cistatic inline int lv1_gpu_fb_close(u64 context_handle)
688c2ecf20Sopenharmony_ci{
698c2ecf20Sopenharmony_ci	return lv1_gpu_context_attribute(context_handle,
708c2ecf20Sopenharmony_ci					 L1GPU_CONTEXT_ATTRIBUTE_FB_CLOSE, 0,
718c2ecf20Sopenharmony_ci					 0, 0, 0);
728c2ecf20Sopenharmony_ci}
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci#endif /* _ASM_POWERPC_PS3GPU_H */
75