1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2016  Nexell Co., Ltd.
4 *
5 * Author: junghyun, kim <jhkim@nexell.co.kr>
6 */
7
8#include <config.h>
9#include <common.h>
10#include <errno.h>
11
12#include <asm/arch/display.h>
13
14#include "soc/s5pxx18_soc_disptop.h"
15
16static int rgb_switch(int module, int input, struct dp_sync_info *sync,
17		      struct dp_rgb_dev *dev)
18{
19	int mpu = dev->lcd_mpu_type;
20	int rsc = 0, sel = 0;
21
22	switch (module) {
23	case 0:
24		sel = mpu ? 1 : 0;
25		break;
26	case 1:
27		sel = rsc ? 3 : 2;
28		break;
29	default:
30		printf("Fail, %s nuknown module %d\n", __func__, module);
31		return -1;
32	}
33
34	nx_disp_top_set_primary_mux(sel);
35	return 0;
36}
37
38void nx_rgb_display(int module,
39		    struct dp_sync_info *sync, struct dp_ctrl_info *ctrl,
40		    struct dp_plane_top *top, struct dp_plane_info *planes,
41		    struct dp_rgb_dev *dev)
42{
43	struct dp_plane_info *plane = planes;
44	int input = module == 0 ? DP_DEVICE_DP0 : DP_DEVICE_DP1;
45	int count = top->plane_num;
46	int i = 0;
47
48	printf("RGB:   dp.%d\n", module);
49
50	dp_control_init(module);
51	dp_plane_init(module);
52
53	/* set plane */
54	dp_plane_screen_setup(module, top);
55
56	for (i = 0; count > i; i++, plane++) {
57		if (!plane->enable)
58			continue;
59		dp_plane_layer_setup(module, plane);
60		dp_plane_layer_enable(module, plane, 1);
61	}
62
63	dp_plane_screen_enable(module, 1);
64
65	rgb_switch(module, input, sync, dev);
66
67	dp_control_setup(module, sync, ctrl);
68	dp_control_enable(module, 1);
69}
70