summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Expand)Author
2022-09-01libcamera: color_space: Move color space adjustment to ColorSpace classUmang Jain
2022-09-01libcamera: colorspace: Rectify the ColorSpace::Srgb presetUmang Jain
2022-09-01libcamera: v4l2_videodevice: Improve toColorSpace() readabilityUmang Jain
2022-09-01libcamera: v4l2_device: Adjust colorspace based on pixel formatUmang Jain
2022-09-01libcamera: v4l2_subdevice: Add color encoding for media bus formatsUmang Jain
2022-08-31libcamera: request: Rename Private::reuse() to Private::reset()Umang Jain
2022-08-30ipa: rkisp1: lsc: Use double instead of float to accumulate vector of doublesMarvin Schmidt
2022-08-30ipa: rkisp1: Remove redundant call of std::string::c_str()Marvin Schmidt
2022-08-30ipa: ipu3: Remove redundant call of std::string::c_str()Marvin Schmidt
2022-08-30libcamera: media_device: Fix \sa tags for MediaDevice::linkMarvin Schmidt
2022-08-30libcamera: pipeline: rkisp1: Implement color space supportLaurent Pinchart
2022-08-26cam: Add color space supportLaurent Pinchart
2022-08-26libcamera: color_space: Add fromString() functionLaurent Pinchart
2022-08-26libcamera: color_space: Reorder members in the same order as the headerLaurent Pinchart
2022-08-25libcamera: color_space: Rename Jpeg to SyccLaurent Pinchart
2022-08-25libcamera: ipu3: Use std::max() instead of expandTo() to get the max resolutionHan-Lin Chen via libcamera-devel
2022-08-25libcamera: Use const reference for range loopsChristian Rauch via libcamera-devel
2022-08-24gstreamer: Add support for additional RGB formatsLaurent Pinchart
2022-08-21ipa: rkisp1: Add support of Denoise Pre-Filter controlFlorian Sylvestre
2022-08-21ipa: rkisp1: Add enable field for LSC algorithm in IPA contextFlorian Sylvestre
2022-08-21ipa: rkisp1: Add enable field for AWB algorithm in IPA contextFlorian Sylvestre
2022-08-21libcamera: yaml_parser: De-duplicate common code in YamlObject::get()Laurent Pinchart
2022-08-21libcamera: yaml_parser: Enable YamlObject::get() for int8_t and uint8_tLaurent Pinchart
2022-08-21libcamera: yaml_parser: Fix bounds checking for 16-bit YamlObject::get()Laurent Pinchart
2022-08-21libcamera: pipeline: rkisp1: Remove unused assignmentChristian Rauch
2022-08-21libcamera: Remove unused headersChristian Rauch
2022-08-20libcamera: v4l2: Set colorspace flagsUmang Jain
2022-08-19ipa: rkisp1: Add manual color gainsPaul Elder
2022-08-19py: Switch to non-blocking eventfdTomi Valkeinen
2022-08-19py: Use libcamera's Mutex classesTomi Valkeinen
2022-08-19py: Set EFD_CLOEXEC on eventfd to avoid fd leakingTomi Valkeinen
2022-08-19py: Use UniqueFDTomi Valkeinen
2022-08-19py: Create PyCameraManagerTomi Valkeinen
2022-08-19py: meson: Use libcamera_private dependencyTomi Valkeinen
2022-08-18py: cam.py: Remove todo commentTomi Valkeinen
2022-08-18py: Move ControlValue helpers to py_helpers.cppTomi Valkeinen
2022-08-18py: Add Python logging categoryTomi Valkeinen
2022-08-18py: cam.py: Fix multi camera capture without -CTomi Valkeinen
2022-08-16libcamera: base: Make message.h and mutex.h privateLaurent Pinchart
2022-08-16meson: Use dependency() instead of find_library() where possibleLaurent Pinchart
2022-08-10libcamera: Allow concurrent use of cameras from same pipeline handlerLaurent Pinchart
2022-08-10libcamera: formats: Fix warning for unknown V4L2 pixfmtJacopo Mondi
2022-08-09ipa: ipu3: Add YAML tuning file supportLaurent Pinchart
2022-08-09ipa: ipu3: Register algorithmsLaurent Pinchart
2022-08-09ipa: ipu3: Add an uncalibrated.yaml tuning data fileLaurent Pinchart
2022-08-09pipeline: ipu3: Support IPA tuning fileLaurent Pinchart
2022-08-09libcamera: yaml_parser: Return nullopt on error from YamlObject::get()Laurent Pinchart
2022-08-09cam: sdl_texture: Rename 'pitch' to 'stride'Laurent Pinchart
2022-08-09ipa: rkisp1: Remove unused algorithms includes from rkisp1.cppDaniel Semkowicz
2022-08-09libcamera: Make IPA module signing recommended instead of mandatoryLaurent Pinchart
405' href='#n405'>405 406 407 408 409 410 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 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 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 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 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 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (C) 2021, Ideas on Board Oy
 *
 * DRM/KMS Helpers
 */

#include "drm.h"

#include <algorithm>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <iostream>
#include <set>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>

#include <libcamera/framebuffer.h>
#include <libcamera/geometry.h>
#include <libcamera/pixel_format.h>

#include <libdrm/drm_mode.h>

#include "../common/event_loop.h"

namespace DRM {

Object::Object(Device *dev, uint32_t id, Type type)
	: id_(id), dev_(dev), type_(type)
{
	/* Retrieve properties from the objects that support them. */
	if (type != TypeConnector && type != TypeCrtc &&
	    type != TypeEncoder && type != TypePlane)
		return;

	/*
	 * We can't distinguish between failures due to the object having no
	 * property and failures due to other conditions. Assume we use the API
	 * correctly and consider the object has no property.
	 */
	drmModeObjectProperties *properties = drmModeObjectGetProperties(dev->fd(), id, type);
	if (!properties)
		return;

	properties_.reserve(properties->count_props);
	for (uint32_t i = 0; i < properties->count_props; ++i)
		properties_.emplace_back(properties->props[i],
					 properties->prop_values[i]);

	drmModeFreeObjectProperties(properties);
}

Object::~Object()
{
}

const Property *Object::property(const std::string &name) const
{
	for (const PropertyValue &pv : properties_) {
		const Property *property = static_cast<const Property *>(dev_->object(pv.id()));
		if (property && property->name() == name)
			return property;
	}

	return nullptr;
}

const PropertyValue *Object::propertyValue(const std::string &name) const
{
	for (const PropertyValue &pv : properties_) {
		const Property *property = static_cast<const Property *>(dev_->object(pv.id()));
		if (property && property->name() == name)
			return &pv;
	}

	return nullptr;
}

Property::Property(Device *dev, drmModePropertyRes *property)
	: Object(dev, property->prop_id, TypeProperty),