/* Given a new render window in new_win, adjust the window to the *nearestsupportedconfiguration.Theadjustedwindowparametersare *returnedinnew_win. *Returnszeroifsuccessful,or-EINVALiftherequestedwindowis *impossibleandcannotreasonablybeadjusted.
*/ int omap_vout_try_window(struct v4l2_framebuffer *fbuf, struct v4l2_window *new_win)
{ struct v4l2_rect try_win;
/* make a working copy of the new_win rectangle */
try_win = new_win->w;
/* adjust the preview window so it fits on the display by clipping any *offscreenareas
*/ if (try_win.left < 0) {
try_win.width += try_win.left;
try_win.left = 0;
} if (try_win.top < 0) {
try_win.height += try_win.top;
try_win.top = 0;
}
try_win.width = (try_win.width < fbuf->fmt.width) ?
try_win.width : fbuf->fmt.width;
try_win.height = (try_win.height < fbuf->fmt.height) ?
try_win.height : fbuf->fmt.height; if (try_win.left + try_win.width > fbuf->fmt.width)
try_win.width = fbuf->fmt.width - try_win.left; if (try_win.top + try_win.height > fbuf->fmt.height)
try_win.height = fbuf->fmt.height - try_win.top;
try_win.width &= ~1;
try_win.height &= ~1;
if (try_win.width <= 0 || try_win.height <= 0) return -EINVAL;
/* We now have a valid preview window, so go with it */
new_win->w = try_win;
new_win->field = V4L2_FIELD_NONE;
new_win->clips = NULL;
new_win->clipcount = 0;
new_win->bitmap = NULL;
/* Given a new render window in new_win, adjust the window to the *nearestsupportedconfiguration.Theimagecroppingwindowincrop *willalsobeadjustedifnecessary.Preferenceisgiventokeepingthe *windowasclosetotherequestedconfigurationaspossible.If *successful,new_win,vout->win,andcropareupdated. *Returnszeroifsuccessful,or-EINVALiftherequestedpreviewwindowis *impossibleandcannotreasonablybeadjusted.
*/ int omap_vout_new_window(struct v4l2_rect *crop, struct v4l2_window *win, struct v4l2_framebuffer *fbuf, struct v4l2_window *new_win)
{ int err;
err = omap_vout_try_window(fbuf, new_win); if (err) return err;
/* Adjust the cropping window to allow for resizing limitation */ if (omap_vout_dss_omap24xx()) { /* For 24xx limit is 8x to 1/2x scaling. */ if ((crop->height/win->w.height) >= 2)
crop->height = win->w.height * 2;
if ((crop->width/win->w.width) >= 2)
crop->width = win->w.width * 2;
if (crop->width > 768) { /* The OMAP2420 vertical resizing line buffer is 768 *pixelswide.Ifthecroppedimageiswiderthan *768pixelsthenitcannotbeverticallyresized.
*/ if (crop->height != win->w.height)
crop->width = 768;
}
} elseif (omap_vout_dss_omap34xx()) { /* For 34xx limit is 8x to 1/4x scaling. */ if ((crop->height/win->w.height) >= 4)
crop->height = win->w.height * 4;
/* Given a new cropping rectangle in new_crop, adjust the cropping rectangle to *thenearestsupportedconfiguration.Theimagerenderwindowinwinwill *alsobeadjustedifnecessary.Thepreviewwindowisadjustedsuchthatthe *horizontalandverticalrescalingratiosstayconstant.Iftherender *windowwouldfalloutsidethedisplayboundaries,thecroppingrectangle *willalsobeadjustedtomaintaintherescalingratios.Ifsuccessful,crop *andwinareupdated. *Returnszeroifsuccessful,or-EINVALiftherequestedcroppingrectangleis *impossibleandcannotreasonablybeadjusted.
*/ int omap_vout_new_crop(struct v4l2_pix_format *pix, struct v4l2_rect *crop, struct v4l2_window *win, struct v4l2_framebuffer *fbuf, conststruct v4l2_rect *new_crop)
{ struct v4l2_rect try_crop; unsignedlong vresize, hresize;
/* make a working copy of the new_crop rectangle */
try_crop = *new_crop;
/* adjust the cropping rectangle so it fits in the image */ if (try_crop.left < 0) {
try_crop.width += try_crop.left;
try_crop.left = 0;
} if (try_crop.top < 0) {
try_crop.height += try_crop.top;
try_crop.top = 0;
}
try_crop.width = (try_crop.width < pix->width) ?
try_crop.width : pix->width;
try_crop.height = (try_crop.height < pix->height) ?
try_crop.height : pix->height; if (try_crop.left + try_crop.width > pix->width)
try_crop.width = pix->width - try_crop.left; if (try_crop.top + try_crop.height > pix->height)
try_crop.height = pix->height - try_crop.top;
try_crop.width &= ~1;
try_crop.height &= ~1;
if (try_crop.width <= 0 || try_crop.height <= 0) return -EINVAL;
if (omap_vout_dss_omap24xx()) { if (try_crop.height != win->w.height) { /* If we're resizing vertically, we can't support a *cropwidthwiderthan768pixels.
*/ if (try_crop.width > 768)
try_crop.width = 768;
}
} /* vertical resizing */
vresize = (1024 * try_crop.height) / win->w.height; if (omap_vout_dss_omap24xx() && (vresize > 2048))
vresize = 2048; elseif (omap_vout_dss_omap34xx() && (vresize > 4096))
vresize = 4096;
win->w.height = ((1024 * try_crop.height) / vresize) & ~1; if (win->w.height == 0)
win->w.height = 2; if (win->w.height + win->w.top > fbuf->fmt.height) { /* We made the preview window extend below the bottom of the *display,soclipittothedisplayboundaryandresizethe *croppingheighttomaintaintheverticalresizingratio.
*/
win->w.height = (fbuf->fmt.height - win->w.top) & ~1; if (try_crop.height == 0)
try_crop.height = 2;
} /* horizontal resizing */
hresize = (1024 * try_crop.width) / win->w.width; if (omap_vout_dss_omap24xx() && (hresize > 2048))
hresize = 2048; elseif (omap_vout_dss_omap34xx() && (hresize > 4096))
hresize = 4096;
win->w.width = ((1024 * try_crop.width) / hresize) & ~1; if (win->w.width == 0)
win->w.width = 2; if (win->w.width + win->w.left > fbuf->fmt.width) { /* We made the preview window extend past the right side of the *display,soclipittothedisplayboundaryandresizethe *croppingwidthtomaintainthehorizontalresizingratio.
*/
win->w.width = (fbuf->fmt.width - win->w.left) & ~1; if (try_crop.width == 0)
try_crop.width = 2;
} if (omap_vout_dss_omap24xx()) { if ((try_crop.height/win->w.height) >= 2)
try_crop.height = win->w.height * 2;
if ((try_crop.width/win->w.width) >= 2)
try_crop.width = win->w.width * 2;
if (try_crop.width > 768) { /* The OMAP2420 vertical resizing line buffer is *768pixelswide.Ifthecroppedimageiswider *than768pixelsthenitcannotbeverticallyresized.
*/ if (try_crop.height != win->w.height)
try_crop.width = 768;
}
} elseif (omap_vout_dss_omap34xx()) { if ((try_crop.height/win->w.height) >= 4)
try_crop.height = win->w.height * 4;
/* Given a new format in pix and fbuf, crop and win *structuresareinitializedtodefaultvalues.crop *isinitializedtothelargestwindowsizethatwillfitonthedisplay.The *cropwindowiscenteredintheimage.winisinitializedto *thesamesizeascropandiscenteredonthedisplay. *Allsizesandoffsetsareconstrainedtobeevennumbers.
*/ void omap_vout_new_format(struct v4l2_pix_format *pix, struct v4l2_framebuffer *fbuf, struct v4l2_rect *crop, struct v4l2_window *win)
{ /* crop defines the preview source window in the image capture *buffer
*/
omap_vout_default_crop(pix, fbuf, crop);
bool omap_vout_dss_omap34xx(void)
{ switch (omapdss_get_version()) { case OMAPDSS_VER_OMAP34xx_ES1: case OMAPDSS_VER_OMAP34xx_ES3: case OMAPDSS_VER_OMAP3630: case OMAPDSS_VER_AM35xx: returntrue; default: returnfalse;
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.2 Sekunden
(vorverarbeitet am 2026-09-28)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.