summaryrefslogtreecommitdiff
path: root/src/ipa/ipu3
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipa/ipu3')
-rw-r--r--src/ipa/ipu3/algorithms/awb.cpp13
-rw-r--r--src/ipa/ipu3/algorithms/awb.h7
-rw-r--r--src/ipa/ipu3/ipa_context.h1
-rw-r--r--src/ipa/ipu3/ipu3.cpp6
4 files changed, 16 insertions, 11 deletions
diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp
index 2d875d0b..3cff9aa4 100644
--- a/src/ipa/ipu3/algorithms/awb.cpp
+++ b/src/ipa/ipu3/algorithms/awb.cpp
@@ -176,6 +176,7 @@ int Awb::configure(IPAContext &context,
[[maybe_unused]] const IPAConfigInfo &configInfo)
{
const ipu3_uapi_grid_config &grid = context.configuration.grid.bdsGrid;
+ stride_ = context.configuration.grid.stride;
cellsPerZoneX_ = std::round(grid.width / static_cast<double>(kAwbStatsSizeX));
cellsPerZoneY_ = std::round(grid.height / static_cast<double>(kAwbStatsSizeY));
@@ -238,8 +239,7 @@ void Awb::generateZones(std::vector<RGB> &zones)
}
/* Translate the IPU3 statistics into the default statistics zone array */
-void Awb::generateAwbStats(const ipu3_uapi_stats_3a *stats,
- const ipu3_uapi_grid_config &grid)
+void Awb::generateAwbStats(const ipu3_uapi_stats_3a *stats)
{
/*
* Generate a (kAwbStatsSizeX x kAwbStatsSizeY) array from the IPU3 grid which is
@@ -247,7 +247,7 @@ void Awb::generateAwbStats(const ipu3_uapi_stats_3a *stats,
*/
for (unsigned int cellY = 0; cellY < kAwbStatsSizeY * cellsPerZoneY_; cellY++) {
for (unsigned int cellX = 0; cellX < kAwbStatsSizeX * cellsPerZoneX_; cellX++) {
- uint32_t cellPosition = (cellY * grid.width + cellX)
+ uint32_t cellPosition = (cellY * stride_ + cellX)
* sizeof(Ipu3AwbCell);
uint32_t zoneX = cellX / cellsPerZoneX_;
uint32_t zoneY = cellY / cellsPerZoneY_;
@@ -322,13 +322,12 @@ void Awb::awbGreyWorld()
asyncResults_.blueGain = blueGain;
}
-void Awb::calculateWBGains(const ipu3_uapi_stats_3a *stats,
- const ipu3_uapi_grid_config &grid)
+void Awb::calculateWBGains(const ipu3_uapi_stats_3a *stats)
{
ASSERT(stats->stats_3a_status.awb_en);
zones_.clear();
clearAwbStats();
- generateAwbStats(stats, grid);
+ generateAwbStats(stats);
generateZones(zones_);
LOG(IPU3Awb, Debug) << "Valid zones: " << zones_.size();
if (zones_.size() > 10) {
@@ -340,7 +339,7 @@ void Awb::calculateWBGains(const ipu3_uapi_stats_3a *stats,
void Awb::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)
{
- calculateWBGains(stats, context.configuration.grid.bdsGrid);
+ calculateWBGains(stats);
/*
* Gains are only recalculated if enough zones were detected.
diff --git a/src/ipa/ipu3/algorithms/awb.h b/src/ipa/ipu3/algorithms/awb.h
index 681d8c2b..b3e0ad82 100644
--- a/src/ipa/ipu3/algorithms/awb.h
+++ b/src/ipa/ipu3/algorithms/awb.h
@@ -74,11 +74,9 @@ public:
};
private:
- void calculateWBGains(const ipu3_uapi_stats_3a *stats,
- const ipu3_uapi_grid_config &grid);
+ void calculateWBGains(const ipu3_uapi_stats_3a *stats);
void generateZones(std::vector<RGB> &zones);
- void generateAwbStats(const ipu3_uapi_stats_3a *stats,
- const ipu3_uapi_grid_config &grid);
+ void generateAwbStats(const ipu3_uapi_stats_3a *stats);
void clearAwbStats();
void awbGreyWorld();
uint32_t estimateCCT(double red, double green, double blue);
@@ -87,6 +85,7 @@ private:
Accumulator awbStats_[kAwbStatsSizeX * kAwbStatsSizeY];
AwbStatus asyncResults_;
+ uint32_t stride_;
uint32_t cellsPerZoneX_;
uint32_t cellsPerZoneY_;
uint32_t cellsPerZoneThreshold_;
diff --git a/src/ipa/ipu3/ipa_context.h b/src/ipa/ipu3/ipa_context.h
index 9d9444dc..5bab684c 100644
--- a/src/ipa/ipu3/ipa_context.h
+++ b/src/ipa/ipu3/ipa_context.h
@@ -20,6 +20,7 @@ struct IPASessionConfiguration {
struct {
ipu3_uapi_grid_config bdsGrid;
Size bdsOutputSize;
+ uint32_t stride;
} grid;
};
diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp
index 757a5d50..06f53fbe 100644
--- a/src/ipa/ipu3/ipu3.cpp
+++ b/src/ipa/ipu3/ipu3.cpp
@@ -91,6 +91,9 @@
*
* \var IPASessionConfiguration::grid::bdsOutputSize
* \brief BDS output size configured by the pipeline handler
+ *
+ * \var IPASessionConfiguration::grid::stride
+ * \brief Number of cells on one line including the ImgU padding
*/
/**
@@ -352,6 +355,9 @@ void IPAIPU3::calculateBdsGrid(const Size &bdsOutputSize)
bdsGrid.height = best.height >> bestLog2.height;
bdsGrid.block_height_log2 = bestLog2.height;
+ /* The ImgU pads the lines to a multiple of 4 cells. */
+ context_.configuration.grid.stride = utils::alignUp(bdsGrid.width, 4);
+
LOG(IPAIPU3, Debug) << "Best grid found is: ("
<< (int)bdsGrid.width << " << " << (int)bdsGrid.block_width_log2 << ") x ("
<< (int)bdsGrid.height << " << " << (int)bdsGrid.block_height_log2 << ")";
13 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
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2019, Google Inc.
 *
 * Thread support
 */

#include <libcamera/base/thread.h>

#include <atomic>
#include <list>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>

#include <libcamera/base/event_dispatcher.h>
#include <libcamera/base/event_dispatcher_poll.h>
#include <libcamera/base/log.h>
#include <libcamera/base/message.h>
#include <libcamera/base/mutex.h>
#include <libcamera/base/object.h>

/**
 * \page thread Thread Support
 *
 * libcamera supports multi-threaded applications through a threading model that
 * sets precise rules to guarantee thread-safe usage of the API. Additionally,
 * libcamera makes internal use of threads, and offers APIs that simplify
 * interactions with application threads. Careful compliance with the threading
 * model will ensure avoidance of race conditions.
 *
 * Every thread created by libcamera is associated with an instance of the
 * Thread class. Those threads run an internal event loop by default to
 * dispatch events to objects. Additionally, the main thread of the application
 * (defined as the thread that calls CameraManager::start()) is also associated
 * with a Thread instance, but has no event loop accessible to libcamera. Other
 * application threads are not visible to libcamera.
 *
 * \section thread-objects Threads and Objects
 *
 * Instances of the Object class and all its derived classes are thread-aware
 * and are bound to the thread they are created in. They are said to *live* in
 * a thread, and they interact with the event loop of their thread for the
 * purpose of message passing and signal delivery. Messages posted to the
 * object with Object::postMessage() will be delivered from the event loop of