static void decon_update_plane(struct exynos_drm_crtc *crtc,
			       struct exynos_drm_plane *plane)
{
	struct exynos_drm_plane_state *state =
				to_exynos_plane_state(plane->base.state);
	struct decon_context *ctx = crtc->ctx;
	struct drm_framebuffer *fb = state->base.fb;
	unsigned int win = plane->index;
	unsigned int bpp = fb->bits_per_pixel >> 3;
	unsigned int pitch = fb->pitches[0];
	dma_addr_t dma_addr = exynos_drm_fb_dma_addr(fb, 0);
	u32 val;

	if (test_bit(BIT_SUSPENDED, &ctx->flags))
		return;

	val = COORDINATE_X(state->crtc.x) | COORDINATE_Y(state->crtc.y);
	writel(val, ctx->addr + DECON_VIDOSDxA(win));

	val = COORDINATE_X(state->crtc.x + state->crtc.w - 1) |
		COORDINATE_Y(state->crtc.y + state->crtc.h - 1);
	writel(val, ctx->addr + DECON_VIDOSDxB(win));

	val = VIDOSD_Wx_ALPHA_R_F(0x0) | VIDOSD_Wx_ALPHA_G_F(0x0) |
		VIDOSD_Wx_ALPHA_B_F(0x0);
	writel(val, ctx->addr + DECON_VIDOSDxC(win));

	val = VIDOSD_Wx_ALPHA_R_F(0x0) | VIDOSD_Wx_ALPHA_G_F(0x0) |
		VIDOSD_Wx_ALPHA_B_F(0x0);
	writel(val, ctx->addr + DECON_VIDOSDxD(win));

	writel(dma_addr, ctx->addr + DECON_VIDW0xADD0B0(win));

	val = dma_addr + pitch * state->src.h;
	writel(val, ctx->addr + DECON_VIDW0xADD1B0(win));

	if (ctx->out_type != IFTYPE_HDMI)
		val = BIT_VAL(pitch - state->crtc.w * bpp, 27, 14)
			| BIT_VAL(state->crtc.w * bpp, 13, 0);
	else
		val = BIT_VAL(pitch - state->crtc.w * bpp, 29, 15)
			| BIT_VAL(state->crtc.w * bpp, 14, 0);
	writel(val, ctx->addr + DECON_VIDW0xADD2(win));

	decon_win_set_pixfmt(ctx, win, fb);

	/* window enable */
	decon_set_bits(ctx, DECON_WINCONx(win), WINCONx_ENWIN_F, ~0);

	/* standalone update */
	decon_set_bits(ctx, DECON_UPDATE, STANDALONE_UPDATE_F, ~0);
}
Esempio n. 2
0
static void decon_update_plane(struct exynos_drm_crtc *crtc,
			       struct exynos_drm_plane *plane)
{
	struct decon_context *ctx = crtc->ctx;
	struct drm_plane_state *state = plane->base.state;
	unsigned int win = plane->zpos;
	unsigned int bpp = state->fb->bits_per_pixel >> 3;
	unsigned int pitch = state->fb->pitches[0];
	u32 val;

	if (test_bit(BIT_SUSPENDED, &ctx->flags))
		return;

	val = COORDINATE_X(plane->crtc_x) | COORDINATE_Y(plane->crtc_y);
	writel(val, ctx->addr + DECON_VIDOSDxA(win));

	val = COORDINATE_X(plane->crtc_x + plane->crtc_w - 1) |
		COORDINATE_Y(plane->crtc_y + plane->crtc_h - 1);
	writel(val, ctx->addr + DECON_VIDOSDxB(win));

	val = VIDOSD_Wx_ALPHA_R_F(0x0) | VIDOSD_Wx_ALPHA_G_F(0x0) |
		VIDOSD_Wx_ALPHA_B_F(0x0);
	writel(val, ctx->addr + DECON_VIDOSDxC(win));

	val = VIDOSD_Wx_ALPHA_R_F(0x0) | VIDOSD_Wx_ALPHA_G_F(0x0) |
		VIDOSD_Wx_ALPHA_B_F(0x0);
	writel(val, ctx->addr + DECON_VIDOSDxD(win));

	writel(plane->dma_addr[0], ctx->addr + DECON_VIDW0xADD0B0(win));

	val = plane->dma_addr[0] + pitch * plane->crtc_h;
	writel(val, ctx->addr + DECON_VIDW0xADD1B0(win));

	if (ctx->out_type != IFTYPE_HDMI)
		val = BIT_VAL(pitch - plane->crtc_w * bpp, 27, 14)
			| BIT_VAL(plane->crtc_w * bpp, 13, 0);
	else
		val = BIT_VAL(pitch - plane->crtc_w * bpp, 29, 15)
			| BIT_VAL(plane->crtc_w * bpp, 14, 0);
	writel(val, ctx->addr + DECON_VIDW0xADD2(win));

	decon_win_set_pixfmt(ctx, win, state->fb);

	/* window enable */
	decon_set_bits(ctx, DECON_WINCONx(win), WINCONx_ENWIN_F, ~0);

	/* standalone update */
	decon_set_bits(ctx, DECON_UPDATE, STANDALONE_UPDATE_F, ~0);
}
Esempio n. 3
0
inline void				write_base(char *buff, int *index, t_pfflags *flags)
{
	if (flags->base > 9)
		buff[++*index] = '0' + flags->base / 10;
	buff[++*index] = '0' + flags->base % 10;
	buff[++*index] = (BIT_VAL(flags->flg, 1) ? 'B' : 'b');
}
Esempio n. 4
0
static inline void		write_rec(uint64_t nbr, char *buff, t_pfflags *flags,
							int *index)
{
	if (nbr > (size_t)(flags->base - 1))
		write_rec(nbr / flags->base, buff, flags, index);
	if (nbr % flags->base < 10)
		buff[++*index] = '0' + nbr % flags->base;
	else
		buff[++*index] = (BIT_VAL(flags->flg, 1) ? 'A' : 'a') + nbr %
			flags->base - 10;
}
Esempio n. 5
0
inline void				write_uint(uint64_t nbr, char *buff, t_pfflags *flags,
							int *index)
{
	int					n;

	if (BIT_VAL(flags->flg, 13))
	{
		n = flags->n_digits - 1;
		while (++n < flags->prec)
			buff[++*index] = '0';
	}
	write_rec(nbr, buff, flags, index);
}
Esempio n. 6
0
// wait while LCD is busy and return address
uint8_t lcd_wait_busy () {
  // set control port to read busy flag and address
  CLEAR_BIT (LCD_CTL_PORT, LCD_RS_PIN);
  SET_BIT (LCD_CTL_PORT, LCD_RW_PIN);
  _delay_us (1);

  uint8_t data = BIT (7);
  while (BIT_VAL (data, 7) == 1) {
    data = read_data ();
    _delay_us (1);
  }

  SET_BIT (LCD_DATA_DDR, LCD_DATA7_PIN); // turn DB7 to output
  clear_all_ctl_pin ();

  return data;
}
Esempio n. 7
0
// Set data port and toggle e pin
void send_data (uint8_t data) {
  uint8_t part;

  // send upper bit
  part = data >> 4;
  SET_VAL (LCD_DATA_PORT, LCD_DATA7_PIN, BIT_VAL(part, 3));
  SET_VAL (LCD_DATA_PORT, LCD_DATA6_PIN, BIT_VAL(part, 2));
  SET_VAL (LCD_DATA_PORT, LCD_DATA5_PIN, BIT_VAL(part, 1));
  SET_VAL (LCD_DATA_PORT, LCD_DATA4_PIN, BIT_VAL(part, 0));
  toggle_e_pin ();

  // send lower bit
  part = data;
  SET_VAL (LCD_DATA_PORT, LCD_DATA7_PIN, BIT_VAL(part, 3));
  SET_VAL (LCD_DATA_PORT, LCD_DATA6_PIN, BIT_VAL(part, 2));
  SET_VAL (LCD_DATA_PORT, LCD_DATA5_PIN, BIT_VAL(part, 1));
  SET_VAL (LCD_DATA_PORT, LCD_DATA4_PIN, BIT_VAL(part, 0));
  toggle_e_pin ();
}
Esempio n. 8
0
uint8_t read_data () {
  // clear_all_data_pin ();
  uint8_t re = 0;
  // set all ports to input
  CLEAR_BIT (LCD_DATA_DDR, LCD_DATA7_PIN);
  CLEAR_BIT (LCD_DATA_DDR, LCD_DATA6_PIN);
  CLEAR_BIT (LCD_DATA_DDR, LCD_DATA5_PIN);
  CLEAR_BIT (LCD_DATA_DDR, LCD_DATA4_PIN);

  //  set_all_data_pin ();

  // received higher bit
  output_high (LCD_CTL_PORT, LCD_E_PIN);
  __asm__ ("NOP");
  re |= BIT_VAL (LCD_DATA_IN, LCD_DATA7_PIN) << 7;
  re |= BIT_VAL (LCD_DATA_IN, LCD_DATA6_PIN) << 6;
  re |= BIT_VAL (LCD_DATA_IN, LCD_DATA5_PIN) << 5;
  re |= BIT_VAL (LCD_DATA_IN, LCD_DATA4_PIN) << 4;
  output_low (LCD_CTL_PORT, LCD_E_PIN);
  __asm__ ("NOP");

  // received lower bit
  output_high (LCD_CTL_PORT, LCD_E_PIN);
  __asm__ ("NOP");
  re |= BIT_VAL (LCD_DATA_IN, LCD_DATA7_PIN) << 3;
  re |= BIT_VAL (LCD_DATA_IN, LCD_DATA6_PIN) << 2;
  re |= BIT_VAL (LCD_DATA_IN, LCD_DATA5_PIN) << 1;
  re |= BIT_VAL (LCD_DATA_IN, LCD_DATA4_PIN);
  output_low (LCD_CTL_PORT, LCD_E_PIN);
  __asm__ ("NOP");

  // set all data ports to output
  SET_BIT (LCD_DATA_DDR, LCD_DATA7_PIN);
  SET_BIT (LCD_DATA_DDR, LCD_DATA6_PIN);
  SET_BIT (LCD_DATA_DDR, LCD_DATA5_PIN);
  SET_BIT (LCD_DATA_DDR, LCD_DATA4_PIN);

  return re;
}
EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy,
				const EGLint *attrib_list, EGLConfig *configs,
				EGLint config_size, EGLint *num_config)
{
	if (unlikely(!fglEGLValidateDisplay(dpy))) {
		setError(EGL_BAD_DISPLAY);
		return EGL_FALSE;
	}

	if (unlikely(!num_config)) {
		setError(EGL_BAD_PARAMETER);
		return EGL_FALSE;
	}

	if (unlikely(!attrib_list)) {
		/*
		 * A NULL attrib_list should be treated as though it was
		 * an empty one (terminated with EGL_NONE) as defined in
		 * section 3.4.1 "Querying Configurations" in the EGL
		 * specification.
		 */
		attrib_list = &dummyAttribList;
	}

	uint32_t numAttributes = 0;
	uint32_t numConfigs = gPlatformConfigsNum;
	uint32_t possibleMatch = BIT_MASK(numConfigs);

	while (possibleMatch && *attrib_list != EGL_NONE) {
		EGLint attr = *(attrib_list++);
		EGLint val  = *(attrib_list++);

		for (uint32_t i = 0; i < numConfigs; ++i) {
			if (!possibleMatch)
				break;

			if (!(possibleMatch & BIT_VAL(i)))
				continue;

			if (!fglIsAttributeMatching(i, attr, val))
				possibleMatch &= ~BIT_VAL(i);
		}

		++numAttributes;
	}

	uint32_t numDefaults = NELEM(defaultConfigAttributes);
	/* now, handle the attributes which have a useful default value */
	for (uint32_t j = 0; j < numDefaults; ++j) {
		if (!possibleMatch)
			break;
		/*
		 * see if this attribute was specified,
		 * if not, apply its default value
		 */
		const FGLConfigPair *array = (const FGLConfigPair *)attrib_list;
		int index = binarySearch(array, 0, numAttributes - 1,
						defaultConfigAttributes[j].key);
		if (index >= 0)
			continue;

		for (uint32_t i = 0; i < numConfigs; ++i) {
			if (!possibleMatch)
				break;

			if (!(possibleMatch & BIT_VAL(i)))
				continue;

			const FGLConfigPair *tmp = &defaultConfigAttributes[i];
			int matched = fglIsAttributeMatching(i,
							tmp->key, tmp->value);
			if (!matched)
				possibleMatch &= ~BIT_VAL(i);
		}
	}

	/* return the configurations found */
	if (!possibleMatch) {
		*num_config = 0;
		return EGL_TRUE;
	}

	uint32_t n = 0;

	if (!configs) {
		while (possibleMatch) {
			n += possibleMatch & 1;
			possibleMatch >>= 1;
		}
		*num_config = n;
		return EGL_TRUE;
	}

	for (uint32_t i = 0; config_size && i < numConfigs; ++i) {
		if (!(possibleMatch & BIT_VAL(i)))
			continue;

		*(configs++) = (EGLConfig)i;
		--config_size;
		++n;
	}

	*num_config = n;
	return EGL_TRUE;
}