Skip to content

Commit 3a7e9d3

Browse files
committed
Merge branch 'master' into next
2 parents c439c27 + 619da07 commit 3a7e9d3

27 files changed

+671
-302
lines changed

src/gstreamer/gstlibcamerapad.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ gst_libcamera_pad_query(GstPad *pad, GstObject *parent, GstQuery *query)
7272
if (query->type != GST_QUERY_LATENCY)
7373
return gst_pad_query_default(pad, parent, query);
7474

75+
GLibLocker lock(GST_OBJECT(self));
76+
if (self->latency == GST_CLOCK_TIME_NONE)
77+
return FALSE;
78+
7579
/* TRUE here means live, we assumes that max latency is the same as min
7680
* as we have no idea that duration of frames. */
7781
gst_query_set_latency(query, TRUE, self->latency, self->latency);
@@ -81,6 +85,7 @@ gst_libcamera_pad_query(GstPad *pad, GstObject *parent, GstQuery *query)
8185
static void
8286
gst_libcamera_pad_init(GstLibcameraPad *self)
8387
{
88+
self->latency = GST_CLOCK_TIME_NONE;
8489
GST_PAD_QUERYFUNC(self) = gst_libcamera_pad_query;
8590
}
8691

src/gstreamer/gstlibcamerasrc.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -881,8 +881,10 @@ gst_libcamera_src_task_leave([[maybe_unused]] GstTask *task,
881881

882882
{
883883
GLibRecLocker locker(&self->stream_lock);
884-
for (GstPad *srcpad : state->srcpads_)
884+
for (GstPad *srcpad : state->srcpads_) {
885+
gst_libcamera_pad_set_latency(srcpad, GST_CLOCK_TIME_NONE);
885886
gst_libcamera_pad_set_pool(srcpad, nullptr);
887+
}
886888
}
887889

888890
g_clear_object(&self->allocator);
@@ -1085,7 +1087,7 @@ gst_libcamera_src_request_new_pad(GstElement *element, GstPadTemplate *templ,
10851087

10861088
gst_child_proxy_child_added(GST_CHILD_PROXY(self), G_OBJECT(pad), GST_OBJECT_NAME(pad));
10871089

1088-
return reinterpret_cast<GstPad *>(g_steal_pointer(&pad));
1090+
return std::exchange(pad, nullptr);
10891091
}
10901092

10911093
static void

src/ipa/rkisp1/algorithms/filter.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ LOG_DEFINE_CATEGORY(RkISP1Filter)
3939
static constexpr uint32_t kFiltLumWeightDefault = 0x00022040;
4040
static constexpr uint32_t kFiltModeDefault = 0x000004f2;
4141

42+
/**
43+
* \copydoc libcamera::ipa::Algorithm::init
44+
*/
45+
int Filter::init(IPAContext &context,
46+
[[maybe_unused]] const YamlObject &tuningData)
47+
{
48+
auto &cmap = context.ctrlMap;
49+
cmap[&controls::Sharpness] = ControlInfo(0.0f, 10.0f, 1.0f);
50+
51+
return 0;
52+
}
4253
/**
4354
* \copydoc libcamera::ipa::Algorithm::queueRequest
4455
*/

src/ipa/rkisp1/algorithms/filter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class Filter : public Algorithm
2121
Filter() = default;
2222
~Filter() = default;
2323

24+
int init(IPAContext &context, const YamlObject &tuningData) override;
2425
void queueRequest(IPAContext &context, const uint32_t frame,
2526
IPAFrameContext &frameContext,
2627
const ControlList &controls) override;

src/ipa/rkisp1/rkisp1.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ const IPAHwSettings ipaHwSettingsV12{
116116
/* List of controls handled by the RkISP1 IPA */
117117
const ControlInfoMap::Map rkisp1Controls{
118118
{ &controls::DebugMetadataEnable, ControlInfo(false, true, false) },
119-
{ &controls::Sharpness, ControlInfo(0.0f, 10.0f, 1.0f) },
120119
{ &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) },
121120
};
122121

src/ipa/rpi/common/ipa_base.cpp

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -238,25 +238,6 @@ int32_t IpaBase::configure(const IPACameraSensorInfo &sensorInfo, const ConfigPa
238238
agcStatus.analogueGain = defaultAnalogueGain;
239239
applyAGC(&agcStatus, ctrls);
240240

241-
/*
242-
* Set the lens to the default (typically hyperfocal) position
243-
* on first start.
244-
*/
245-
if (lensPresent_) {
246-
RPiController::AfAlgorithm *af =
247-
dynamic_cast<RPiController::AfAlgorithm *>(controller_.getAlgorithm("af"));
248-
249-
if (af) {
250-
float defaultPos =
251-
ipaAfControls.at(&controls::LensPosition).def().get<float>();
252-
ControlList lensCtrl(lensCtrls_);
253-
int32_t hwpos;
254-
255-
af->setLensPosition(defaultPos, &hwpos);
256-
lensCtrl.set(V4L2_CID_FOCUS_ABSOLUTE, hwpos);
257-
result->lensControls = std::move(lensCtrl);
258-
}
259-
}
260241
}
261242

262243
result->sensorControls = std::move(ctrls);
@@ -286,8 +267,20 @@ int32_t IpaBase::configure(const IPACameraSensorInfo &sensorInfo, const ConfigPa
286267
ctrlMap.merge(ControlInfoMap::Map(ipaColourControls));
287268

288269
/* Declare Autofocus controls, only if we have a controllable lens */
289-
if (lensPresent_)
270+
if (lensPresent_) {
290271
ctrlMap.merge(ControlInfoMap::Map(ipaAfControls));
272+
RPiController::AfAlgorithm *af =
273+
dynamic_cast<RPiController::AfAlgorithm *>(controller_.getAlgorithm("af"));
274+
if (af) {
275+
double min, max, dflt;
276+
af->getLensLimits(min, max);
277+
dflt = af->getDefaultLensPosition();
278+
ctrlMap[&controls::LensPosition] =
279+
ControlInfo(static_cast<float>(min),
280+
static_cast<float>(max),
281+
static_cast<float>(dflt));
282+
}
283+
}
291284

292285
result->controlInfo = ControlInfoMap(std::move(ctrlMap), controls::controls);
293286

@@ -325,6 +318,26 @@ void IpaBase::start(const ControlList &controls, StartResult *result)
325318
/* Make a note of this as it tells us the HDR status of the first few frames. */
326319
hdrStatus_ = agcStatus.hdr;
327320

321+
/*
322+
* AF: If no lens position was specified, drive lens to a default position.
323+
* This had to be deferred (not initialised by a constructor) until here
324+
* to ensure that exactly ONE starting position is sent to the lens driver.
325+
* It should be the static API default, not dependent on AF range or mode.
326+
*/
327+
if (firstStart_ && lensPresent_) {
328+
RPiController::AfAlgorithm *af = dynamic_cast<RPiController::AfAlgorithm *>(
329+
controller_.getAlgorithm("af"));
330+
if (af && !af->getLensPosition()) {
331+
int32_t hwpos;
332+
double pos = af->getDefaultLensPosition();
333+
if (af->setLensPosition(pos, &hwpos, true)) {
334+
ControlList lensCtrls(lensCtrls_);
335+
lensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE, hwpos);
336+
setLensControls.emit(lensCtrls);
337+
}
338+
}
339+
}
340+
328341
/*
329342
* Initialise frame counts, and decide how many frames must be hidden or
330343
* "mistrusted", which depends on whether this is a startup from cold,

src/ipa/rpi/controller/af_algorithm.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ class AfAlgorithm : public Algorithm
3333
*
3434
* getMode() is provided mainly for validating controls.
3535
* getLensPosition() is provided for populating DeviceStatus.
36+
*
37+
* getDefaultlensPosition() and getLensLimits() were added for
38+
* populating ControlInfoMap. They return the static API limits
39+
* which should be independent of the current range or mode.
3640
*/
3741

3842
enum AfRange { AfRangeNormal = 0,
@@ -66,7 +70,9 @@ class AfAlgorithm : public Algorithm
6670
}
6771
virtual void setMode(AfMode mode) = 0;
6872
virtual AfMode getMode() const = 0;
69-
virtual bool setLensPosition(double dioptres, int32_t *hwpos) = 0;
73+
virtual double getDefaultLensPosition() const = 0;
74+
virtual void getLensLimits(double &min, double &max) const = 0;
75+
virtual bool setLensPosition(double dioptres, int32_t *hwpos, bool force = false) = 0;
7076
virtual std::optional<double> getLensPosition() const = 0;
7177
virtual void triggerScan() = 0;
7278
virtual void cancelScan() = 0;

0 commit comments

Comments
 (0)