From patchwork Thu Oct 25 15:02:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Neuhaus X-Patchwork-Id: 1644801 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id D63703FC36 for ; Thu, 25 Oct 2012 15:02:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1946018Ab2JYPC4 (ORCPT ); Thu, 25 Oct 2012 11:02:56 -0400 Received: from ch1ehsobe005.messaging.microsoft.com ([216.32.181.185]:52306 "EHLO ch1outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933842Ab2JYPCz convert rfc822-to-8bit (ORCPT ); Thu, 25 Oct 2012 11:02:55 -0400 Received: from mail157-ch1-R.bigfish.com (10.43.68.229) by CH1EHSOBE015.bigfish.com (10.43.70.65) with Microsoft SMTP Server id 14.1.225.23; Thu, 25 Oct 2012 15:02:53 +0000 Received: from mail157-ch1 (localhost [127.0.0.1]) by mail157-ch1-R.bigfish.com (Postfix) with ESMTP id D8A7B360295; Thu, 25 Oct 2012 15:02:53 +0000 (UTC) X-Forefront-Antispam-Report: CIP:157.56.249.213; KIP:(null); UIP:(null); IPV:NLI; H:AM2PRD0710HT003.eurprd07.prod.outlook.com; RD:none; EFVD:NLI X-SpamScore: -1 X-BigFish: PS-1(zz936eIzz1d18h1202h1d1ah1d2ahzzz2dh2a8h668h839h944hd25hf0ah1220h1288h12a5h12a9h12bdh137ah13b6h1441h1504h1537h153bh1155h) Received: from mail157-ch1 (localhost.localdomain [127.0.0.1]) by mail157-ch1 (MessageSwitch) id 1351177372118593_13921; Thu, 25 Oct 2012 15:02:52 +0000 (UTC) Received: from CH1EHSMHS036.bigfish.com (snatpool1.int.messaging.microsoft.com [10.43.68.249]) by mail157-ch1.bigfish.com (Postfix) with ESMTP id 117162A007C; Thu, 25 Oct 2012 15:02:52 +0000 (UTC) Received: from AM2PRD0710HT003.eurprd07.prod.outlook.com (157.56.249.213) by CH1EHSMHS036.bigfish.com (10.43.69.245) with Microsoft SMTP Server (TLS) id 14.1.225.23; Thu, 25 Oct 2012 15:02:50 +0000 Received: from AM2PRD0710MB375.eurprd07.prod.outlook.com ([169.254.10.98]) by AM2PRD0710HT003.eurprd07.prod.outlook.com ([10.255.165.38]) with mapi id 14.16.0224.004; Thu, 25 Oct 2012 15:02:47 +0000 From: Florian Neuhaus To: "Laurent Pinchart (laurent.pinchart@ideasonboard.com)" CC: "linux-media@vger.kernel.org" Subject: [PATCH] Rotate the videout via V4L2_CID_ROTATE based on fb_var_screeninfo.rotate Thread-Topic: [PATCH] Rotate the videout via V4L2_CID_ROTATE based on fb_var_screeninfo.rotate Thread-Index: Ac2ywMccUuvyoJWsQnCoY9xMIznZVg== Date: Thu, 25 Oct 2012 15:02:46 +0000 Message-ID: <6EE9CD707FBED24483D4CB0162E8546710079A2F@AM2PRD0710MB375.eurprd07.prod.outlook.com> Accept-Language: de-CH, en-US Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [188.60.57.40] MIME-Version: 1.0 X-OriginatorOrg: reberinformatik.ch Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Hi Laurent You are very fast on implementing new features in omap3-isp-live. I appreciate much the new panning-feature - thank you! On my beagleboard I use omap-vout with vrfb-rotation. As I already configured omapfb to rotate the screen upon start (kernel-argument omapfb.rotate), I thought it might be useful to rotate omap-vout accordingly in your application. This is what the following patch does. The patch is a diff against your latest commit 619164a994c8d878249d6c1b8b16c27074a04209. I hope it is useful. Greetings, Florian --- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff -rupN '--exclude=.git' omap3-isp-live/live.c omap3-isp-live-voisee/live.c --- omap3-isp-live/live.c 2012-10-24 18:14:58.830555741 +0200 +++ omap3-isp-live-voisee/live.c 2012-10-24 22:28:49.278056954 +0200 @@ -661,7 +674,36 @@ struct color_rgb24 { unsigned int value:24; } __attribute__((__packed__)); -static int fb_init(struct v4l2_rect *rect) +/* + * Convert DSS rotation to V4L2 rotation + * V4L2 understand 0, 90, 180, 270 degrees. + */ +static int dss_rot_to_v4l2_rot(int dss_rotation, + int *v4l2_rotation) +{ + int ret = 0; + + switch (dss_rotation) { + case 1: + *v4l2_rotation = 90; + break; + case 2: + *v4l2_rotation = 180; + break; + case 3: + *v4l2_rotation = 270; + break; + case 0: + *v4l2_rotation = 0; + break; + default: + ret = -EINVAL; + break; + } + return ret; +} + +static int fb_init(struct v4l2_rect *rect, int *rotation) { struct color_24bpp ; @@ -745,6 +787,8 @@ static int fb_init(struct v4l2_rect *rec rect->width = var.xres; rect->height = var.yres; + /* Return the rotation (if any) in degrees */ + dss_rot_to_v4l2_rot(var.rotate, rotation); done: if (mem != NULL) munmap(mem, fix.smem_len); @@ -812,6 +858,7 @@ int main(int argc __attribute__((__unuse unsigned int colorkey; bool enable_aewb = true; float fps; + int rotation; int ret; int c; @@ -851,10 +898,10 @@ int main(int argc __attribute__((__unuse } events_init(&events); input_init(&input); memset(&rect, 0, sizeof rect); - ret = fb_init(&rect); + ret = fb_init(&rect, &rotation); if (ret < 0) { printf("error: unable to initialize frame buffer\n"); goto cleanup; @@ -879,7 +929,7 @@ int main(int argc __attribute__((__unuse format.pixelformat = V4L2_PIX_FMT_YUYV; format.width = rect.width; format.height = rect.height; - vo = vo_init(vo_devname, &vo_ops, buffers, &format); + vo = vo_init(vo_devname, &vo_ops, buffers, &format, rotation); if (vo == NULL) { printf("error: unable to initialize video output\n"); goto cleanup; diff -rupN '--exclude=.git' omap3-isp-live/snapshot.c omap3-isp-live-voisee/snapshot.c --- omap3-isp-live/snapshot.c 2012-10-24 18:14:58.830555741 +0200 +++ omap3-isp-live-voisee/snapshot.c 2012-10-24 22:28:49.274057063 +0200 @@ -45,6 +45,7 @@ #if USE_LIBJPEG #include #include +#include "jpeg.h" #endif #include "isp/list.h" @@ -55,7 +56,6 @@ #include "events.h" #include "iq.h" -#include "jpeg.h" #define MEDIA_DEVICE "/dev/media0" diff -rupN '--exclude=.git' omap3-isp-live/videoout.c omap3-isp-live-voisee/videoout.c --- omap3-isp-live/videoout.c 2012-09-28 14:43:53.978198906 +0200 +++ omap3-isp-live-voisee/videoout.c 2012-10-24 22:28:49.278056954 +0200 @@ -54,7 +54,8 @@ struct videoout struct videoout *vo_init(const char *devname, const struct video_out_operations *ops, unsigned int buffers, - struct v4l2_pix_format *format) + struct v4l2_pix_format *format, + int rotation) { struct v4l2_pix_format pixfmt; struct v4l2_format fmt; @@ -76,6 +77,14 @@ struct videoout *vo_init(const char *dev goto error; } + /* setup the rotation here, we have to do it BEFORE + * setting the format. */ + ret = v4l2_set_control(vo->dev, V4L2_CID_ROTATE, &rotation); + if (ret < 0){ + perror("Failed to setup rotation\n"); + goto error; + } + pixfmt.pixelformat = format->pixelformat; pixfmt.width = format->width; pixfmt.height = format->height; diff -rupN '--exclude=.git' omap3-isp-live/videoout.h omap3-isp-live-voisee/videoout.h --- omap3-isp-live/videoout.h 2012-09-28 14:43:53.978198906 +0200 +++ omap3-isp-live-voisee/videoout.h 2012-10-24 22:28:49.274057063 +0200 @@ -34,10 +34,13 @@ struct video_out_operations { void (*unwatch_fd)(int fd); }; +int vo_set_rotation(struct videoout *vo, int rotation); + struct videoout *vo_init(const char *devname, const struct video_out_operations *ops, unsigned int buffers, - struct v4l2_pix_format *format); + struct v4l2_pix_format *format, + int rotation); void vo_cleanup(struct videoout *vo); int vo_enable_colorkey(struct videoout *vo, unsigned int val);