overlay.c 15.0 KB
Newer Older
T
Tomi Valkeinen 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
/*
 * linux/drivers/video/omap2/dss/overlay.c
 *
 * Copyright (C) 2009 Nokia Corporation
 * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
 *
 * Some code and ideas taken from drivers/video/omap/ driver
 * by Imre Deak.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published by
 * the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#define DSS_SUBSYS_NAME "OVERLAY"

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/err.h>
#include <linux/sysfs.h>
#include <linux/kobject.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
32
#include <linux/slab.h>
T
Tomi Valkeinen 已提交
33

34
#include <video/omapdss.h>
T
Tomi Valkeinen 已提交
35 36 37
#include <plat/cpu.h>

#include "dss.h"
38
#include "dss_features.h"
T
Tomi Valkeinen 已提交
39 40

static int num_overlays;
41
static struct omap_overlay *overlays;
T
Tomi Valkeinen 已提交
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68

static ssize_t overlay_name_show(struct omap_overlay *ovl, char *buf)
{
	return snprintf(buf, PAGE_SIZE, "%s\n", ovl->name);
}

static ssize_t overlay_manager_show(struct omap_overlay *ovl, char *buf)
{
	return snprintf(buf, PAGE_SIZE, "%s\n",
			ovl->manager ? ovl->manager->name : "<none>");
}

static ssize_t overlay_manager_store(struct omap_overlay *ovl, const char *buf,
		size_t size)
{
	int i, r;
	struct omap_overlay_manager *mgr = NULL;
	struct omap_overlay_manager *old_mgr;
	int len = size;

	if (buf[size-1] == '\n')
		--len;

	if (len > 0) {
		for (i = 0; i < omap_dss_get_num_overlay_managers(); ++i) {
			mgr = omap_dss_get_overlay_manager(i);

69
			if (sysfs_streq(buf, mgr->name))
T
Tomi Valkeinen 已提交
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
				break;

			mgr = NULL;
		}
	}

	if (len > 0 && mgr == NULL)
		return -EINVAL;

	if (mgr)
		DSSDBG("manager %s found\n", mgr->name);

	if (mgr == ovl->manager)
		return size;

	old_mgr = ovl->manager;

87 88 89 90
	r = dispc_runtime_get();
	if (r)
		return r;

T
Tomi Valkeinen 已提交
91 92 93 94 95
	/* detach old manager */
	if (old_mgr) {
		r = ovl->unset_manager(ovl);
		if (r) {
			DSSERR("detach failed\n");
96
			goto err;
T
Tomi Valkeinen 已提交
97 98 99 100
		}

		r = old_mgr->apply(old_mgr);
		if (r)
101
			goto err;
T
Tomi Valkeinen 已提交
102 103 104 105 106 107
	}

	if (mgr) {
		r = ovl->set_manager(ovl, mgr);
		if (r) {
			DSSERR("Failed to attach overlay\n");
108
			goto err;
T
Tomi Valkeinen 已提交
109 110 111 112
		}

		r = mgr->apply(mgr);
		if (r)
113
			goto err;
T
Tomi Valkeinen 已提交
114 115
	}

116 117
	dispc_runtime_put();

T
Tomi Valkeinen 已提交
118
	return size;
119 120 121 122

err:
	dispc_runtime_put();
	return r;
T
Tomi Valkeinen 已提交
123 124 125 126
}

static ssize_t overlay_input_size_show(struct omap_overlay *ovl, char *buf)
{
127 128 129 130
	struct omap_overlay_info info;

	ovl->get_overlay_info(ovl, &info);

T
Tomi Valkeinen 已提交
131
	return snprintf(buf, PAGE_SIZE, "%d,%d\n",
132
			info.width, info.height);
T
Tomi Valkeinen 已提交
133 134 135 136
}

static ssize_t overlay_screen_width_show(struct omap_overlay *ovl, char *buf)
{
137 138 139 140 141
	struct omap_overlay_info info;

	ovl->get_overlay_info(ovl, &info);

	return snprintf(buf, PAGE_SIZE, "%d\n", info.screen_width);
T
Tomi Valkeinen 已提交
142 143 144 145
}

static ssize_t overlay_position_show(struct omap_overlay *ovl, char *buf)
{
146 147 148 149
	struct omap_overlay_info info;

	ovl->get_overlay_info(ovl, &info);

T
Tomi Valkeinen 已提交
150
	return snprintf(buf, PAGE_SIZE, "%d,%d\n",
151
			info.pos_x, info.pos_y);
T
Tomi Valkeinen 已提交
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
}

static ssize_t overlay_position_store(struct omap_overlay *ovl,
		const char *buf, size_t size)
{
	int r;
	char *last;
	struct omap_overlay_info info;

	ovl->get_overlay_info(ovl, &info);

	info.pos_x = simple_strtoul(buf, &last, 10);
	++last;
	if (last - buf >= size)
		return -EINVAL;

	info.pos_y = simple_strtoul(last, &last, 10);

	r = ovl->set_overlay_info(ovl, &info);
	if (r)
		return r;

	if (ovl->manager) {
		r = ovl->manager->apply(ovl->manager);
		if (r)
			return r;
	}

	return size;
}

static ssize_t overlay_output_size_show(struct omap_overlay *ovl, char *buf)
{
185 186 187 188
	struct omap_overlay_info info;

	ovl->get_overlay_info(ovl, &info);

T
Tomi Valkeinen 已提交
189
	return snprintf(buf, PAGE_SIZE, "%d,%d\n",
190
			info.out_width, info.out_height);
T
Tomi Valkeinen 已提交
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
}

static ssize_t overlay_output_size_store(struct omap_overlay *ovl,
		const char *buf, size_t size)
{
	int r;
	char *last;
	struct omap_overlay_info info;

	ovl->get_overlay_info(ovl, &info);

	info.out_width = simple_strtoul(buf, &last, 10);
	++last;
	if (last - buf >= size)
		return -EINVAL;

	info.out_height = simple_strtoul(last, &last, 10);

	r = ovl->set_overlay_info(ovl, &info);
	if (r)
		return r;

	if (ovl->manager) {
		r = ovl->manager->apply(ovl->manager);
		if (r)
			return r;
	}

	return size;
}

static ssize_t overlay_enabled_show(struct omap_overlay *ovl, char *buf)
{
224
	return snprintf(buf, PAGE_SIZE, "%d\n", ovl->is_enabled(ovl));
T
Tomi Valkeinen 已提交
225 226 227 228 229
}

static ssize_t overlay_enabled_store(struct omap_overlay *ovl, const char *buf,
		size_t size)
{
230 231
	int r;
	bool enable;
T
Tomi Valkeinen 已提交
232

233
	r = strtobool(buf, &enable);
234 235 236
	if (r)
		return r;

237 238 239 240
	if (enable)
		r = ovl->enable(ovl);
	else
		r = ovl->disable(ovl);
T
Tomi Valkeinen 已提交
241 242 243 244 245 246 247 248 249

	if (r)
		return r;

	return size;
}

static ssize_t overlay_global_alpha_show(struct omap_overlay *ovl, char *buf)
{
250 251 252 253
	struct omap_overlay_info info;

	ovl->get_overlay_info(ovl, &info);

T
Tomi Valkeinen 已提交
254
	return snprintf(buf, PAGE_SIZE, "%d\n",
255
			info.global_alpha);
T
Tomi Valkeinen 已提交
256 257 258 259 260 261
}

static ssize_t overlay_global_alpha_store(struct omap_overlay *ovl,
		const char *buf, size_t size)
{
	int r;
262
	u8 alpha;
T
Tomi Valkeinen 已提交
263 264
	struct omap_overlay_info info;

265
	if ((ovl->caps & OMAP_DSS_OVL_CAP_GLOBAL_ALPHA) == 0)
266 267
		return -ENODEV;

268 269 270 271
	r = kstrtou8(buf, 0, &alpha);
	if (r)
		return r;

T
Tomi Valkeinen 已提交
272 273
	ovl->get_overlay_info(ovl, &info);

274
	info.global_alpha = alpha;
T
Tomi Valkeinen 已提交
275 276 277 278 279 280 281 282 283 284 285 286 287 288

	r = ovl->set_overlay_info(ovl, &info);
	if (r)
		return r;

	if (ovl->manager) {
		r = ovl->manager->apply(ovl->manager);
		if (r)
			return r;
	}

	return size;
}

289 290 291
static ssize_t overlay_pre_mult_alpha_show(struct omap_overlay *ovl,
		char *buf)
{
292 293 294 295
	struct omap_overlay_info info;

	ovl->get_overlay_info(ovl, &info);

296
	return snprintf(buf, PAGE_SIZE, "%d\n",
297
			info.pre_mult_alpha);
298 299 300 301 302 303
}

static ssize_t overlay_pre_mult_alpha_store(struct omap_overlay *ovl,
		const char *buf, size_t size)
{
	int r;
304
	u8 alpha;
305 306
	struct omap_overlay_info info;

307 308 309
	if ((ovl->caps & OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA) == 0)
		return -ENODEV;

310 311 312 313
	r = kstrtou8(buf, 0, &alpha);
	if (r)
		return r;

314 315
	ovl->get_overlay_info(ovl, &info);

316
	info.pre_mult_alpha = alpha;
317 318 319 320 321 322 323 324 325 326 327 328 329 330

	r = ovl->set_overlay_info(ovl, &info);
	if (r)
		return r;

	if (ovl->manager) {
		r = ovl->manager->apply(ovl->manager);
		if (r)
			return r;
	}

	return size;
}

331 332
static ssize_t overlay_zorder_show(struct omap_overlay *ovl, char *buf)
{
333 334 335 336 337
	struct omap_overlay_info info;

	ovl->get_overlay_info(ovl, &info);

	return snprintf(buf, PAGE_SIZE, "%d\n", info.zorder);
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370
}

static ssize_t overlay_zorder_store(struct omap_overlay *ovl,
		const char *buf, size_t size)
{
	int r;
	u8 zorder;
	struct omap_overlay_info info;

	if ((ovl->caps & OMAP_DSS_OVL_CAP_ZORDER) == 0)
		return -ENODEV;

	r = kstrtou8(buf, 0, &zorder);
	if (r)
		return r;

	ovl->get_overlay_info(ovl, &info);

	info.zorder = zorder;

	r = ovl->set_overlay_info(ovl, &info);
	if (r)
		return r;

	if (ovl->manager) {
		r = ovl->manager->apply(ovl->manager);
		if (r)
			return r;
	}

	return size;
}

T
Tomi Valkeinen 已提交
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
struct overlay_attribute {
	struct attribute attr;
	ssize_t (*show)(struct omap_overlay *, char *);
	ssize_t	(*store)(struct omap_overlay *, const char *, size_t);
};

#define OVERLAY_ATTR(_name, _mode, _show, _store) \
	struct overlay_attribute overlay_attr_##_name = \
	__ATTR(_name, _mode, _show, _store)

static OVERLAY_ATTR(name, S_IRUGO, overlay_name_show, NULL);
static OVERLAY_ATTR(manager, S_IRUGO|S_IWUSR,
		overlay_manager_show, overlay_manager_store);
static OVERLAY_ATTR(input_size, S_IRUGO, overlay_input_size_show, NULL);
static OVERLAY_ATTR(screen_width, S_IRUGO, overlay_screen_width_show, NULL);
static OVERLAY_ATTR(position, S_IRUGO|S_IWUSR,
		overlay_position_show, overlay_position_store);
static OVERLAY_ATTR(output_size, S_IRUGO|S_IWUSR,
		overlay_output_size_show, overlay_output_size_store);
static OVERLAY_ATTR(enabled, S_IRUGO|S_IWUSR,
		overlay_enabled_show, overlay_enabled_store);
static OVERLAY_ATTR(global_alpha, S_IRUGO|S_IWUSR,
		overlay_global_alpha_show, overlay_global_alpha_store);
394 395 396
static OVERLAY_ATTR(pre_mult_alpha, S_IRUGO|S_IWUSR,
		overlay_pre_mult_alpha_show,
		overlay_pre_mult_alpha_store);
397 398
static OVERLAY_ATTR(zorder, S_IRUGO|S_IWUSR,
		overlay_zorder_show, overlay_zorder_store);
T
Tomi Valkeinen 已提交
399 400 401 402 403 404 405 406 407 408

static struct attribute *overlay_sysfs_attrs[] = {
	&overlay_attr_name.attr,
	&overlay_attr_manager.attr,
	&overlay_attr_input_size.attr,
	&overlay_attr_screen_width.attr,
	&overlay_attr_position.attr,
	&overlay_attr_output_size.attr,
	&overlay_attr_enabled.attr,
	&overlay_attr_global_alpha.attr,
409
	&overlay_attr_pre_mult_alpha.attr,
410
	&overlay_attr_zorder.attr,
T
Tomi Valkeinen 已提交
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443
	NULL
};

static ssize_t overlay_attr_show(struct kobject *kobj, struct attribute *attr,
		char *buf)
{
	struct omap_overlay *overlay;
	struct overlay_attribute *overlay_attr;

	overlay = container_of(kobj, struct omap_overlay, kobj);
	overlay_attr = container_of(attr, struct overlay_attribute, attr);

	if (!overlay_attr->show)
		return -ENOENT;

	return overlay_attr->show(overlay, buf);
}

static ssize_t overlay_attr_store(struct kobject *kobj, struct attribute *attr,
		const char *buf, size_t size)
{
	struct omap_overlay *overlay;
	struct overlay_attribute *overlay_attr;

	overlay = container_of(kobj, struct omap_overlay, kobj);
	overlay_attr = container_of(attr, struct overlay_attribute, attr);

	if (!overlay_attr->store)
		return -ENOENT;

	return overlay_attr->store(overlay, buf, size);
}

444
static const struct sysfs_ops overlay_sysfs_ops = {
T
Tomi Valkeinen 已提交
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461
	.show = overlay_attr_show,
	.store = overlay_attr_store,
};

static struct kobj_type overlay_ktype = {
	.sysfs_ops = &overlay_sysfs_ops,
	.default_attrs = overlay_sysfs_attrs,
};

int omap_dss_get_num_overlays(void)
{
	return num_overlays;
}
EXPORT_SYMBOL(omap_dss_get_num_overlays);

struct omap_overlay *omap_dss_get_overlay(int num)
{
462 463
	if (num >= num_overlays)
		return NULL;
T
Tomi Valkeinen 已提交
464

465
	return &overlays[num];
T
Tomi Valkeinen 已提交
466 467 468 469 470 471 472
}
EXPORT_SYMBOL(omap_dss_get_overlay);

void dss_init_overlays(struct platform_device *pdev)
{
	int i, r;

473
	num_overlays = dss_feat_get_num_ovls();
T
Tomi Valkeinen 已提交
474

475 476
	overlays = kzalloc(sizeof(struct omap_overlay) * num_overlays,
			GFP_KERNEL);
T
Tomi Valkeinen 已提交
477

478
	BUG_ON(overlays == NULL);
T
Tomi Valkeinen 已提交
479

480 481
	for (i = 0; i < num_overlays; ++i) {
		struct omap_overlay *ovl = &overlays[i];
T
Tomi Valkeinen 已提交
482 483 484 485 486 487 488 489 490 491 492 493 494 495

		switch (i) {
		case 0:
			ovl->name = "gfx";
			ovl->id = OMAP_DSS_GFX;
			break;
		case 1:
			ovl->name = "vid1";
			ovl->id = OMAP_DSS_VIDEO1;
			break;
		case 2:
			ovl->name = "vid2";
			ovl->id = OMAP_DSS_VIDEO2;
			break;
496 497 498 499
		case 3:
			ovl->name = "vid3";
			ovl->id = OMAP_DSS_VIDEO3;
			break;
T
Tomi Valkeinen 已提交
500 501
		}

502 503 504
		ovl->is_enabled = &dss_ovl_is_enabled;
		ovl->enable = &dss_ovl_enable;
		ovl->disable = &dss_ovl_disable;
505 506 507 508
		ovl->set_manager = &dss_ovl_set_manager;
		ovl->unset_manager = &dss_ovl_unset_manager;
		ovl->set_overlay_info = &dss_ovl_set_info;
		ovl->get_overlay_info = &dss_ovl_get_info;
509
		ovl->wait_for_go = &dss_mgr_wait_for_go_ovl;
T
Tomi Valkeinen 已提交
510

511
		ovl->caps = dss_feat_get_overlay_caps(ovl->id);
512 513 514
		ovl->supported_modes =
			dss_feat_get_supported_color_modes(ovl->id);

T
Tomi Valkeinen 已提交
515 516 517
		r = kobject_init_and_add(&ovl->kobj, &overlay_ktype,
				&pdev->dev.kobj, "overlay%d", i);

518
		if (r)
T
Tomi Valkeinen 已提交
519 520 521 522 523 524 525 526 527 528 529
			DSSERR("failed to create sysfs file\n");
	}
}

/* connect overlays to the new device, if not already connected. if force
 * selected, connect always. */
void dss_recheck_connections(struct omap_dss_device *dssdev, bool force)
{
	int i;
	struct omap_overlay_manager *lcd_mgr;
	struct omap_overlay_manager *tv_mgr;
530
	struct omap_overlay_manager *lcd2_mgr = NULL;
531
	struct omap_overlay_manager *lcd3_mgr = NULL;
T
Tomi Valkeinen 已提交
532 533
	struct omap_overlay_manager *mgr = NULL;

534 535
	lcd_mgr = omap_dss_get_overlay_manager(OMAP_DSS_CHANNEL_LCD);
	tv_mgr = omap_dss_get_overlay_manager(OMAP_DSS_CHANNEL_DIGIT);
536 537
	if (dss_has_feature(FEAT_MGR_LCD3))
		lcd3_mgr = omap_dss_get_overlay_manager(OMAP_DSS_CHANNEL_LCD3);
538
	if (dss_has_feature(FEAT_MGR_LCD2))
539
		lcd2_mgr = omap_dss_get_overlay_manager(OMAP_DSS_CHANNEL_LCD2);
540

541 542 543 544 545 546 547 548
	if (dssdev->channel == OMAP_DSS_CHANNEL_LCD3) {
		if (!lcd3_mgr->device || force) {
			if (lcd3_mgr->device)
				lcd3_mgr->unset_device(lcd3_mgr);
			lcd3_mgr->set_device(lcd3_mgr, dssdev);
			mgr = lcd3_mgr;
		}
	} else if (dssdev->channel == OMAP_DSS_CHANNEL_LCD2) {
549 550 551 552 553 554
		if (!lcd2_mgr->device || force) {
			if (lcd2_mgr->device)
				lcd2_mgr->unset_device(lcd2_mgr);
			lcd2_mgr->set_device(lcd2_mgr, dssdev);
			mgr = lcd2_mgr;
		}
555 556
	} else if (dssdev->type != OMAP_DISPLAY_TYPE_VENC
			&& dssdev->type != OMAP_DISPLAY_TYPE_HDMI) {
T
Tomi Valkeinen 已提交
557 558 559 560 561 562 563 564
		if (!lcd_mgr->device || force) {
			if (lcd_mgr->device)
				lcd_mgr->unset_device(lcd_mgr);
			lcd_mgr->set_device(lcd_mgr, dssdev);
			mgr = lcd_mgr;
		}
	}

565 566
	if (dssdev->type == OMAP_DISPLAY_TYPE_VENC
			|| dssdev->type == OMAP_DISPLAY_TYPE_HDMI) {
T
Tomi Valkeinen 已提交
567 568 569 570 571 572 573 574 575
		if (!tv_mgr->device || force) {
			if (tv_mgr->device)
				tv_mgr->unset_device(tv_mgr);
			tv_mgr->set_device(tv_mgr, dssdev);
			mgr = tv_mgr;
		}
	}

	if (mgr) {
576 577
		dispc_runtime_get();

578
		for (i = 0; i < dss_feat_get_num_ovls(); i++) {
T
Tomi Valkeinen 已提交
579 580 581 582
			struct omap_overlay *ovl;
			ovl = omap_dss_get_overlay(i);
			if (!ovl->manager || force) {
				if (ovl->manager)
583 584
					ovl->unset_manager(ovl);
				ovl->set_manager(ovl, mgr);
T
Tomi Valkeinen 已提交
585 586
			}
		}
587 588

		dispc_runtime_put();
T
Tomi Valkeinen 已提交
589 590 591 592 593
	}
}

void dss_uninit_overlays(struct platform_device *pdev)
{
594 595 596 597
	int i;

	for (i = 0; i < num_overlays; ++i) {
		struct omap_overlay *ovl = &overlays[i];
T
Tomi Valkeinen 已提交
598 599 600 601 602

		kobject_del(&ovl->kobj);
		kobject_put(&ovl->kobj);
	}

603 604
	kfree(overlays);
	overlays = NULL;
T
Tomi Valkeinen 已提交
605 606 607
	num_overlays = 0;
}

608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640
int dss_ovl_simple_check(struct omap_overlay *ovl,
		const struct omap_overlay_info *info)
{
	if (info->paddr == 0) {
		DSSERR("check_overlay: paddr cannot be 0\n");
		return -EINVAL;
	}

	if ((ovl->caps & OMAP_DSS_OVL_CAP_SCALE) == 0) {
		if (info->out_width != 0 && info->width != info->out_width) {
			DSSERR("check_overlay: overlay %d doesn't support "
					"scaling\n", ovl->id);
			return -EINVAL;
		}

		if (info->out_height != 0 && info->height != info->out_height) {
			DSSERR("check_overlay: overlay %d doesn't support "
					"scaling\n", ovl->id);
			return -EINVAL;
		}
	}

	if ((ovl->supported_modes & info->color_mode) == 0) {
		DSSERR("check_overlay: overlay %d doesn't support mode %d\n",
				ovl->id, info->color_mode);
		return -EINVAL;
	}

	if (info->zorder >= omap_dss_get_num_overlays()) {
		DSSERR("check_overlay: zorder %d too high\n", info->zorder);
		return -EINVAL;
	}

641 642 643 644 645 646
	if (dss_feat_rotation_type_supported(info->rotation_type) == 0) {
		DSSERR("check_overlay: rotation type %d not supported\n",
				info->rotation_type);
		return -EINVAL;
	}

647 648 649
	return 0;
}

650 651
int dss_ovl_check(struct omap_overlay *ovl, struct omap_overlay_info *info,
		const struct omap_video_timings *mgr_timings)
652 653 654 655
{
	u16 outw, outh;
	u16 dw, dh;

656 657
	dw = mgr_timings->x_res;
	dh = mgr_timings->y_res;
658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689

	if ((ovl->caps & OMAP_DSS_OVL_CAP_SCALE) == 0) {
		outw = info->width;
		outh = info->height;
	} else {
		if (info->out_width == 0)
			outw = info->width;
		else
			outw = info->out_width;

		if (info->out_height == 0)
			outh = info->height;
		else
			outh = info->out_height;
	}

	if (dw < info->pos_x + outw) {
		DSSERR("overlay %d horizontally not inside the display area "
				"(%d + %d >= %d)\n",
				ovl->id, info->pos_x, outw, dw);
		return -EINVAL;
	}

	if (dh < info->pos_y + outh) {
		DSSERR("overlay %d vertically not inside the display area "
				"(%d + %d >= %d)\n",
				ovl->id, info->pos_y, outh, dh);
		return -EINVAL;
	}

	return 0;
}