Пример #1
0
static void sti_mixer_set_background_area(struct sti_mixer *mixer,
					  struct drm_display_mode *mode)
{
	u32 ydo, xdo, yds, xds;

	ydo = sti_vtg_get_line_number(*mode, 0);
	yds = sti_vtg_get_line_number(*mode, mode->vdisplay - 1);
	xdo = sti_vtg_get_pixel_number(*mode, 0);
	xds = sti_vtg_get_pixel_number(*mode, mode->hdisplay - 1);

	sti_mixer_reg_write(mixer, GAM_MIXER_BCO, ydo << 16 | xdo);
	sti_mixer_reg_write(mixer, GAM_MIXER_BCS, yds << 16 | xds);
}
Пример #2
0
int sti_mixer_active_video_area(struct sti_mixer *mixer,
				struct drm_display_mode *mode)
{
	u32 ydo, xdo, yds, xds;

	ydo = sti_vtg_get_line_number(*mode, 0);
	yds = sti_vtg_get_line_number(*mode, mode->vdisplay - 1);
	xdo = sti_vtg_get_pixel_number(*mode, 0);
	xds = sti_vtg_get_pixel_number(*mode, mode->hdisplay - 1);

	DRM_DEBUG_DRIVER("%s active video area xdo:%d ydo:%d xds:%d yds:%d\n",
			 sti_mixer_to_str(mixer), xdo, ydo, xds, yds);
	sti_mixer_reg_write(mixer, GAM_MIXER_AVO, ydo << 16 | xdo);
	sti_mixer_reg_write(mixer, GAM_MIXER_AVS, yds << 16 | xds);

	sti_mixer_set_background_color(mixer, 0xFF, 0, 0);

	sti_mixer_set_background_area(mixer, mode);
	sti_mixer_set_background_status(mixer, true);
	return 0;
}
Пример #3
0
/**
 * sti_gdp_prepare_layer
 * @lay: gdp layer
 * @first_prepare: true if it is the first time this function is called
 *
 * Update the free GDP node list according to the layer properties.
 *
 * RETURNS:
 * 0 on success.
 */
static int sti_gdp_prepare_layer(struct sti_layer *layer, bool first_prepare)
{
    struct sti_gdp_node_list *list;
    struct sti_gdp_node *top_field, *btm_field;
    struct drm_display_mode *mode = layer->mode;
    struct device *dev = layer->dev;
    struct sti_gdp *gdp = to_sti_gdp(layer);
    struct sti_compositor *compo = dev_get_drvdata(dev);
    int format;
    unsigned int depth, bpp;
    int rate = mode->clock * 1000;
    int res;
    u32 ydo, xdo, yds, xds;

    list = sti_gdp_get_free_nodes(layer);
    top_field = list->top_field;
    btm_field = list->btm_field;

    dev_dbg(dev, "%s %s top_node:0x%p btm_node:0x%p\n", __func__,
            sti_layer_to_str(layer), top_field, btm_field);

    /* Build the top field from layer params */
    top_field->gam_gdp_agc = GAM_GDP_AGC_FULL_RANGE;
    top_field->gam_gdp_ctl = WAIT_NEXT_VSYNC;
    format = sti_gdp_fourcc2format(layer->format);
    if (format == -1) {
        DRM_ERROR("Format not supported by GDP %.4s\n",
                  (char *)&layer->format);
        return 1;
    }
    top_field->gam_gdp_ctl |= format;
    top_field->gam_gdp_ctl |= sti_gdp_get_alpharange(format);
    top_field->gam_gdp_ppt &= ~GAM_GDP_PPT_IGNORE;

    /* pixel memory location */
    drm_fb_get_bpp_depth(layer->format, &depth, &bpp);
    top_field->gam_gdp_pml = (u32) layer->paddr + layer->offsets[0];
    top_field->gam_gdp_pml += layer->src_x * (bpp >> 3);
    top_field->gam_gdp_pml += layer->src_y * layer->pitches[0];

    /* input parameters */
    top_field->gam_gdp_pmp = layer->pitches[0];
    top_field->gam_gdp_size =
        clamp_val(layer->src_h, 0, GAM_GDP_SIZE_MAX) << 16 |
        clamp_val(layer->src_w, 0, GAM_GDP_SIZE_MAX);

    /* output parameters */
    ydo = sti_vtg_get_line_number(*mode, layer->dst_y);
    yds = sti_vtg_get_line_number(*mode, layer->dst_y + layer->dst_h - 1);
    xdo = sti_vtg_get_pixel_number(*mode, layer->dst_x);
    xds = sti_vtg_get_pixel_number(*mode, layer->dst_x + layer->dst_w - 1);
    top_field->gam_gdp_vpo = (ydo << 16) | xdo;
    top_field->gam_gdp_vps = (yds << 16) | xds;

    /* Same content and chained together */
    memcpy(btm_field, top_field, sizeof(*btm_field));
    top_field->gam_gdp_nvn = virt_to_dma(dev, btm_field);
    btm_field->gam_gdp_nvn = virt_to_dma(dev, top_field);

    /* Interlaced mode */
    if (layer->mode->flags & DRM_MODE_FLAG_INTERLACE)
        btm_field->gam_gdp_pml = top_field->gam_gdp_pml +
                                 layer->pitches[0];

    if (first_prepare) {
        /* Register gdp callback */
        if (sti_vtg_register_client(layer->mixer_id == STI_MIXER_MAIN ?
                                    compo->vtg_main : compo->vtg_aux,
                                    &gdp->vtg_field_nb, layer->mixer_id)) {
            DRM_ERROR("Cannot register VTG notifier\n");
            return 1;
        }

        /* Set and enable gdp clock */
        if (gdp->clk_pix) {
            res = clk_set_rate(gdp->clk_pix, rate);
            if (res < 0) {
                DRM_ERROR("Cannot set rate (%dHz) for gdp\n",
                          rate);
                return 1;
            }

            if (clk_prepare_enable(gdp->clk_pix)) {
                DRM_ERROR("Failed to prepare/enable gdp\n");
                return 1;
            }
        }
    }

    return 0;
}