[{"id":1732,"web_url":"https://patchwork.libcamera.org/comment/1732/","msgid":"<741abf7a-216c-1ac4-45e6-c51fb0958c90@ideasonboard.com>","date":"2019-05-31T08:38:16","subject":"Re: [libcamera-devel] [PATCH] qcam: Allow user to select pixel\n\tformat and resolution","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Niklas,\n\nOn 28/05/2019 19:16, Niklas Söderlund wrote:\n> Allow users to select pixel format and resolution from two selection\n> dialogues. Ideally the dialog should be turned into a toolbar with an\n> additional start/stop stream button, but this allows us to demonstrate\n> the selection interface for now.\n\nSmall concern about a rogue return statement below....\n\nIt would certainly be nicer to have an interface to be able to\nsee/configure all of the controls and options - but that will take time\n- so I think a dialog box will do for the moment....\n\n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n>  src/qcam/main_window.cpp | 64 ++++++++++++++++++++++++++++++++++++++--\n>  src/qcam/main_window.h   |  1 +\n>  2 files changed, 63 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\n> index 16b123132dd96cbe..20a87bbf9a8a2514 100644\n> --- a/src/qcam/main_window.cpp\n> +++ b/src/qcam/main_window.cpp\n> @@ -93,11 +93,71 @@ int MainWindow::openCamera()\n>  \treturn 0;\n>  }\n>  \n> -int MainWindow::startCapture()\n> +int MainWindow::selectFormat()\n>  {\n> -\tint ret;\n> +\tQStringList list;\n> +\tQString name;\n> +\tbool result;\n>  \n>  \tconfig_ = camera_->generateConfiguration({ StreamRole::VideoRecording });\n> +\n> +\tStreamConfiguration &cfg = config_->at(0);\n> +\n> +\tconst std::vector<unsigned int> &pixelformats = cfg.formats().pixelformats();\n> +\tif (pixelformats.size()) {\n> +\t\tfor (unsigned int pixelformat : pixelformats)\n> +\t\t\tlist.append(QString::fromStdString(std::to_string(pixelformat)));\n> +\n> +\t\tname = QInputDialog::getItem(this, \"Select pixel format\",\n> +\t\t\t\t\t     \"Pixel format:\", list, 0,\n> +\t\t\t\t\t     false, &result);\n> +\t\tif (!result)\n> +\t\t\treturn -EINVAL;\n> +\n> +\t\tcfg.pixelFormat = pixelformats.at(list.indexOf(name));\n> +\t}\n> +\n> +\tconst std::vector<Size> &sizes = cfg.formats().sizes(cfg.pixelFormat);\n> +\tif (sizes.size()) {\n> +\t\tlist.clear();\n> +\t\tfor (const Size &size : sizes)\n> +\t\t\tlist.append(QString::fromStdString(size.toString()));\n> +\n> +\t\tname = QInputDialog::getItem(this, \"Select resolution\",\n> +\t\t\t\t\t     \"Resolution:\", list, 0,\n> +\t\t\t\t\t     false, &result);\n> +\t\tif (!result)\n> +\t\t\treturn -EINVAL;\n> +\n> +\t\tcfg.size = sizes.at(list.indexOf(name));\n> +\t}\n> +\n> +\tstd::cout << \"Trying to use stream configuration\" << cfg.toString() << std::endl;\n\n/configuration\"/configuration \"/\n\n> +\treturn 0;\n\nUhm...  ^^^^^^^^ ... ?\n\n> +\n> +\tswitch (config_->validate()) {\n> +\tcase CameraConfiguration::Valid:\n> +\t\tbreak;\n> +\tcase CameraConfiguration::Adjusted:\n> +\t\tstd::cout << \"Camera configuration adjusted\" << std::endl;\n> +\t\tbreak;\n> +\tcase CameraConfiguration::Invalid:\n> +\t\tstd::cout << \"Camera configuration invalid\" << std::endl;\n> +\t\tconfig_.reset();\n> +\t\treturn -EINVAL;\n> +\t}\n> +\n> +\treturn 0;\n> +}\n> +\n> +int MainWindow::startCapture()\n> +{\n> +\tint ret;\n> +\n> +\tret = selectFormat();\n> +\tif (ret)\n> +\t\treturn ret;\n> +\n>  \tret = camera_->configure(config_.get());\n>  \tif (ret < 0) {\n>  \t\tstd::cout << \"Failed to configure camera\" << std::endl;\n> diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\n> index fe565cbcb4603d9d..43d2d3e3894fb444 100644\n> --- a/src/qcam/main_window.h\n> +++ b/src/qcam/main_window.h\n> @@ -34,6 +34,7 @@ public:\n>  \n>  private:\n>  \tint openCamera();\n> +\tint selectFormat();\n>  \n>  \tint startCapture();\n>  \tvoid stopCapture();\n>","headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9DEC560E44\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 31 May 2019 10:38:19 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1089C524;\n\tFri, 31 May 2019 10:38:18 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1559291899;\n\tbh=tIEdRCzZrK1bxVJjJyGtvOTd1U48S/jSEWefvQV/TjA=;\n\th=Reply-To:Subject:To:References:From:Date:In-Reply-To:From;\n\tb=Z+0exe1YlH5c2GgdSb5EvMU9iwuaZ3lEGdAJ9anlcHhW9Z1L52ddOQX3RdxkTJrMz\n\tZA7nsnvlXC/X/twC63pkz+bomXVzp3g4R7H0OdXOoRARa0Fn4FFK8HoMOxOvxwXV3b\n\t3qrwc+ZhJZ84Oo96e/K73a1tkPh2CN+J9Cli0Y3c=","Reply-To":"kieran.bingham@ideasonboard.com","To":"=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20190528181654.10649-1-niklas.soderlund@ragnatech.se>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Openpgp":"preference=signencrypt","Autocrypt":"addr=kieran.bingham@ideasonboard.com; keydata=\n\tmQINBFYE/WYBEACs1PwjMD9rgCu1hlIiUA1AXR4rv2v+BCLUq//vrX5S5bjzxKAryRf0uHat\n\tV/zwz6hiDrZuHUACDB7X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C2JL/LOEpw8DGf5BNOP1KgjCvyp1/KcFxDAo89IeqljaRsCdP\n\t7WCIECWYem6pLwaw6IAL7oX+tEqIMPph/G/jwZcdS6Hkyt/esHPuHNwX4guqTbVEuRqbDzDI\n\t2DJO5FbxABEBAAGJAiUEGAEKAA8CGwwFAlnDlGsFCQeA/gIACgkQoR5GchCkYf1yYRAAq+Yo\n\tnbf9DGdK1kTAm2RTFg+w9oOp2Xjqfhds2PAhFFvrHQg1XfQR/UF/SjeUmaOmLSczM0s6XMeO\n\tVcE77UFtJ/+hLo4PRFKm5X1Pcar6g5m4xGqa+Xfzi9tRkwC29KMCoQOag1BhHChgqYaUH3yo\n\tUzaPwT/fY75iVI+yD0ih/e6j8qYvP8pvGwMQfrmN9YB0zB39YzCSdaUaNrWGD3iCBxg6lwSO\n\tLKeRhxxfiXCIYEf3vwOsP3YMx2JkD5doseXmWBGW1U0T/oJF+DVfKB6mv5UfsTzpVhJRgee7\n\t4jkjqFq4qsUGxcvF2xtRkfHFpZDbRgRlVmiWkqDkT4qMA+4q1y/dWwshSKi/uwVZNycuLsz+\n\t+OD8xPNCsMTqeUkAKfbD8xW4LCay3r/dD2ckoxRxtMD9eOAyu5wYzo/ydIPTh1QEj9SYyvp8\n\tO0g6CpxEwyHUQtF5oh15O018z3ZLztFJKR3RD42VKVsrnNDKnoY0f4U0z7eJv2NeF8xHMuiU\n\tRCIzqxX1GVYaNkKTnb/Qja8hnYnkUzY1Lc+OtwiGmXTwYsPZjjAaDX35J/RSKAoy5wGo/YFA\n\tJxB1gWThL4kOTbsqqXj9GLcyOImkW0lJGGR3o/fV91Zh63S5TKnf2YGGGzxki+ADdxVQAm+Q\n\tsbsRB8KNNvVXBOVNwko86rQqF9drZuw=","Organization":"Ideas on Board","Message-ID":"<741abf7a-216c-1ac4-45e6-c51fb0958c90@ideasonboard.com>","Date":"Fri, 31 May 2019 09:38:16 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101\n\tThunderbird/60.6.1","MIME-Version":"1.0","In-Reply-To":"<20190528181654.10649-1-niklas.soderlund@ragnatech.se>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH] qcam: Allow user to select pixel\n\tformat and resolution","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Fri, 31 May 2019 08:38:19 -0000"}},{"id":1739,"web_url":"https://patchwork.libcamera.org/comment/1739/","msgid":"<20190603105604.GD4933@pendragon.ideasonboard.com>","date":"2019-06-03T10:56:04","subject":"Re: [libcamera-devel] [PATCH] qcam: Allow user to select pixel\n\tformat and resolution","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nThank you for the patch.\n\nOn Tue, May 28, 2019 at 08:16:54PM +0200, Niklas Söderlund wrote:\n> Allow users to select pixel format and resolution from two selection\n> dialogues. Ideally the dialog should be turned into a toolbar with an\n> additional start/stop stream button, but this allows us to demonstrate\n> the selection interface for now.\n\nHow difficult do you think it would be to implement such a toolbar ?\n\n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n>  src/qcam/main_window.cpp | 64 ++++++++++++++++++++++++++++++++++++++--\n>  src/qcam/main_window.h   |  1 +\n>  2 files changed, 63 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\n> index 16b123132dd96cbe..20a87bbf9a8a2514 100644\n> --- a/src/qcam/main_window.cpp\n> +++ b/src/qcam/main_window.cpp\n> @@ -93,11 +93,71 @@ int MainWindow::openCamera()\n>  \treturn 0;\n>  }\n>  \n> -int MainWindow::startCapture()\n> +int MainWindow::selectFormat()\n>  {\n> -\tint ret;\n> +\tQStringList list;\n> +\tQString name;\n> +\tbool result;\n>  \n>  \tconfig_ = camera_->generateConfiguration({ StreamRole::VideoRecording });\n> +\n> +\tStreamConfiguration &cfg = config_->at(0);\n> +\n> +\tconst std::vector<unsigned int> &pixelformats = cfg.formats().pixelformats();\n\ns/pixelformats/pixelFormats/ ?\n\n> +\tif (pixelformats.size()) {\n\n\tif (!pixelformats.empty()) {\n\n> +\t\tfor (unsigned int pixelformat : pixelformats)\n> +\t\t\tlist.append(QString::fromStdString(std::to_string(pixelformat)));\n\nHow about using the 4CC code instead of the numerical value ? Otherwise\nyou could use QString::number() instead of going through an std::string.\n\nShouldn't we also limit the formats to the ones that qcam supports ?\n\n> +\n> +\t\tname = QInputDialog::getItem(this, \"Select pixel format\",\n> +\t\t\t\t\t     \"Pixel format:\", list, 0,\n> +\t\t\t\t\t     false, &result);\n> +\t\tif (!result)\n> +\t\t\treturn -EINVAL;\n> +\n> +\t\tcfg.pixelFormat = pixelformats.at(list.indexOf(name));\n> +\t}\n> +\n> +\tconst std::vector<Size> &sizes = cfg.formats().sizes(cfg.pixelFormat);\n> +\tif (sizes.size()) {\n\nYou can use .empty() here too.\n\n> +\t\tlist.clear();\n> +\t\tfor (const Size &size : sizes)\n> +\t\t\tlist.append(QString::fromStdString(size.toString()));\n> +\n> +\t\tname = QInputDialog::getItem(this, \"Select resolution\",\n> +\t\t\t\t\t     \"Resolution:\", list, 0,\n> +\t\t\t\t\t     false, &result);\n> +\t\tif (!result)\n> +\t\t\treturn -EINVAL;\n> +\n> +\t\tcfg.size = sizes.at(list.indexOf(name));\n> +\t}\n\nThat's a total of 3 dialog boxes when starting the application, it's not\nvery nice :-( Could we combine them all into a single dialog box, so\nthat pressing enter once would be enough ?\n\n> +\n> +\tstd::cout << \"Trying to use stream configuration\" << cfg.toString() << std::endl;\n> +\treturn 0;\n> +\n> +\tswitch (config_->validate()) {\n> +\tcase CameraConfiguration::Valid:\n> +\t\tbreak;\n> +\tcase CameraConfiguration::Adjusted:\n> +\t\tstd::cout << \"Camera configuration adjusted\" << std::endl;\n> +\t\tbreak;\n> +\tcase CameraConfiguration::Invalid:\n> +\t\tstd::cout << \"Camera configuration invalid\" << std::endl;\n> +\t\tconfig_.reset();\n> +\t\treturn -EINVAL;\n> +\t}\n> +\n> +\treturn 0;\n> +}\n> +\n> +int MainWindow::startCapture()\n> +{\n> +\tint ret;\n> +\n> +\tret = selectFormat();\n> +\tif (ret)\n> +\t\treturn ret;\n> +\n>  \tret = camera_->configure(config_.get());\n>  \tif (ret < 0) {\n>  \t\tstd::cout << \"Failed to configure camera\" << std::endl;\n> diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\n> index fe565cbcb4603d9d..43d2d3e3894fb444 100644\n> --- a/src/qcam/main_window.h\n> +++ b/src/qcam/main_window.h\n> @@ -34,6 +34,7 @@ public:\n>  \n>  private:\n>  \tint openCamera();\n> +\tint selectFormat();\n>  \n>  \tint startCapture();\n>  \tvoid stopCapture();","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1D3F560BD7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  3 Jun 2019 12:56:17 +0200 (CEST)","from pendragon.ideasonboard.com (unknown\n\t[IPv6:2a02:2788:668:163:5bb7:9f6c:564c:d55e])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id AE730530;\n\tMon,  3 Jun 2019 12:56:16 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1559559376;\n\tbh=4OQ//GajgPDZisfvUYKK1K/6Sf/adl1R3uA9ndU+qLk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=X1v8lOsSvSY1ZzcmbVBlOFqaymzT/2/xk5F9kR5xWnMfw2+lROeXy1lUyPovWpRl4\n\t11upiKTJS3nDozyVSW2z06m4YziRT7ycIycmlN2WxcUYpvXmnlcDK793PxQFrL+FVM\n\tmV7y9geovU0eCWer1yZJODUspY3JKOcnnZFQPBmM=","Date":"Mon, 3 Jun 2019 13:56:04 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190603105604.GD4933@pendragon.ideasonboard.com>","References":"<20190528181654.10649-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190528181654.10649-1-niklas.soderlund@ragnatech.se>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH] qcam: Allow user to select pixel\n\tformat and resolution","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Mon, 03 Jun 2019 10:56:17 -0000"}},{"id":1746,"web_url":"https://patchwork.libcamera.org/comment/1746/","msgid":"<20190603232412.GG2960@bigcity.dyn.berto.se>","date":"2019-06-03T23:24:12","subject":"Re: [libcamera-devel] [PATCH] qcam: Allow user to select pixel\n\tformat and resolution","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Kieran,\n\nThanks for your feedback.\n\nOn 2019-05-31 09:38:16 +0100, Kieran Bingham wrote:\n> Hi Niklas,\n> \n> On 28/05/2019 19:16, Niklas Söderlund wrote:\n> > Allow users to select pixel format and resolution from two selection\n> > dialogues. Ideally the dialog should be turned into a toolbar with an\n> > additional start/stop stream button, but this allows us to demonstrate\n> > the selection interface for now.\n> \n> Small concern about a rogue return statement below....\n\nYes that should not be there... It was added to not scare my seat \nneighbor on my flight who seemed a bit distressed that I kept taking \npictures of my self ;-)\n\n> \n> It would certainly be nicer to have an interface to be able to\n> see/configure all of the controls and options - but that will take time\n> - so I think a dialog box will do for the moment....\n\nLets see what happens, a better interface would indeed be better...\n\n> \n> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> > ---\n> >  src/qcam/main_window.cpp | 64 ++++++++++++++++++++++++++++++++++++++--\n> >  src/qcam/main_window.h   |  1 +\n> >  2 files changed, 63 insertions(+), 2 deletions(-)\n> > \n> > diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\n> > index 16b123132dd96cbe..20a87bbf9a8a2514 100644\n> > --- a/src/qcam/main_window.cpp\n> > +++ b/src/qcam/main_window.cpp\n> > @@ -93,11 +93,71 @@ int MainWindow::openCamera()\n> >  \treturn 0;\n> >  }\n> >  \n> > -int MainWindow::startCapture()\n> > +int MainWindow::selectFormat()\n> >  {\n> > -\tint ret;\n> > +\tQStringList list;\n> > +\tQString name;\n> > +\tbool result;\n> >  \n> >  \tconfig_ = camera_->generateConfiguration({ StreamRole::VideoRecording });\n> > +\n> > +\tStreamConfiguration &cfg = config_->at(0);\n> > +\n> > +\tconst std::vector<unsigned int> &pixelformats = cfg.formats().pixelformats();\n> > +\tif (pixelformats.size()) {\n> > +\t\tfor (unsigned int pixelformat : pixelformats)\n> > +\t\t\tlist.append(QString::fromStdString(std::to_string(pixelformat)));\n> > +\n> > +\t\tname = QInputDialog::getItem(this, \"Select pixel format\",\n> > +\t\t\t\t\t     \"Pixel format:\", list, 0,\n> > +\t\t\t\t\t     false, &result);\n> > +\t\tif (!result)\n> > +\t\t\treturn -EINVAL;\n> > +\n> > +\t\tcfg.pixelFormat = pixelformats.at(list.indexOf(name));\n> > +\t}\n> > +\n> > +\tconst std::vector<Size> &sizes = cfg.formats().sizes(cfg.pixelFormat);\n> > +\tif (sizes.size()) {\n> > +\t\tlist.clear();\n> > +\t\tfor (const Size &size : sizes)\n> > +\t\t\tlist.append(QString::fromStdString(size.toString()));\n> > +\n> > +\t\tname = QInputDialog::getItem(this, \"Select resolution\",\n> > +\t\t\t\t\t     \"Resolution:\", list, 0,\n> > +\t\t\t\t\t     false, &result);\n> > +\t\tif (!result)\n> > +\t\t\treturn -EINVAL;\n> > +\n> > +\t\tcfg.size = sizes.at(list.indexOf(name));\n> > +\t}\n> > +\n> > +\tstd::cout << \"Trying to use stream configuration\" << cfg.toString() << std::endl;\n> \n> /configuration\"/configuration \"/\n> \n> > +\treturn 0;\n> \n> Uhm...  ^^^^^^^^ ... ?\n> \n> > +\n> > +\tswitch (config_->validate()) {\n> > +\tcase CameraConfiguration::Valid:\n> > +\t\tbreak;\n> > +\tcase CameraConfiguration::Adjusted:\n> > +\t\tstd::cout << \"Camera configuration adjusted\" << std::endl;\n> > +\t\tbreak;\n> > +\tcase CameraConfiguration::Invalid:\n> > +\t\tstd::cout << \"Camera configuration invalid\" << std::endl;\n> > +\t\tconfig_.reset();\n> > +\t\treturn -EINVAL;\n> > +\t}\n> > +\n> > +\treturn 0;\n> > +}\n> > +\n> > +int MainWindow::startCapture()\n> > +{\n> > +\tint ret;\n> > +\n> > +\tret = selectFormat();\n> > +\tif (ret)\n> > +\t\treturn ret;\n> > +\n> >  \tret = camera_->configure(config_.get());\n> >  \tif (ret < 0) {\n> >  \t\tstd::cout << \"Failed to configure camera\" << std::endl;\n> > diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\n> > index fe565cbcb4603d9d..43d2d3e3894fb444 100644\n> > --- a/src/qcam/main_window.h\n> > +++ b/src/qcam/main_window.h\n> > @@ -34,6 +34,7 @@ public:\n> >  \n> >  private:\n> >  \tint openCamera();\n> > +\tint selectFormat();\n> >  \n> >  \tint startCapture();\n> >  \tvoid stopCapture();\n> > \n> \n> -- \n> Regards\n> --\n> Kieran","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lj1-x241.google.com (mail-lj1-x241.google.com\n\t[IPv6:2a00:1450:4864:20::241])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B976D60BD7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  4 Jun 2019 01:24:14 +0200 (CEST)","by mail-lj1-x241.google.com with SMTP id h11so17904762ljb.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 03 Jun 2019 16:24:14 -0700 (PDT)","from localhost (89-233-230-99.cust.bredband2.com. [89.233.230.99])\n\tby smtp.gmail.com with ESMTPSA id\n\ty9sm3434882ljc.2.2019.06.03.16.24.13\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tMon, 03 Jun 2019 16:24:13 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to\n\t:user-agent; bh=vRPzbtl07OoUKP1N9GEeh7pahEWME09f++xL0+URHZA=;\n\tb=fZ9hbPgf4FYvrf1+Uex9BN3CbtL+2HHTqL/yUc+A8qKKSuPWQqseLMZZn1zG7Rxi+j\n\t4petvkxF2O6H0mDt4uAs8dIJ+1D/7B0t0RLXAsjZC77USQUf1noUW+74kmE6UNVEJXBA\n\tO0nqrcdGOx/6d569Ex5MqolH9y/CUj0bw0/Xj/t9c7M2j6EK/KVhFJyNjI35DWeaiz9z\n\twL0yi2V39VR29rkpTcO7bdCBoYyxQWFcrE230LXsHfiKpaCTjxKybx9626WDzMcg6bqg\n\tBFqYgzllOFByWS0w7EvYchIAvJyzOqzhobgjrEZsS0+XD2ewfVf/NIgbb5eyULDBhIGX\n\t+5GQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to:user-agent;\n\tbh=vRPzbtl07OoUKP1N9GEeh7pahEWME09f++xL0+URHZA=;\n\tb=mgNJleR1Y9HAWn+tBITjur1sc12nJ6Kd2xL//Zmr0KivL6oFLnVKcPsnRR8fV7FxDZ\n\tN02poBzX0hkawf17Ih+W3h0wK/MP7m/2X2hWodDco0hu0tQmmpcYKlVyzRKvIH2CecMi\n\tTSE5m5PFBdw7jwYj8MJz+00oCim4xW50ubltl+kklKPJe1KSuCdygBgIlSVJAcdKH3LU\n\tG284Xt7iXI6r8OfNhWABngn5uYUptmRy/njq4VjvpFCYGC8WVu5EEuQx3SsG1vk4MV/W\n\tw6YwA3M6vOlJJiRvoEVkTWXJiLe6ABBWCMsO1rBVYQPVXC3q2pEv/KADWZLLF0UXjaKq\n\tFrig==","X-Gm-Message-State":"APjAAAVnx6oQeGLRL2+sCj8vRlujE9EYYrSA9gJ5PoZ1V8p3nzA5e1vB\n\tNaq6ZMx8PNzQ4WRFsYecM/2XuTgYaXQ=","X-Google-Smtp-Source":"APXvYqyGJrxN92BeDySRRuCd5rwJjjx5uEydrjDnWlbznY2NsA1DZ04Wc/LUmpX00cV4Et8bptgvow==","X-Received":"by 2002:a2e:98d5:: with SMTP id\n\ts21mr12301762ljj.142.1559604254259; \n\tMon, 03 Jun 2019 16:24:14 -0700 (PDT)","Date":"Tue, 4 Jun 2019 01:24:12 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190603232412.GG2960@bigcity.dyn.berto.se>","References":"<20190528181654.10649-1-niklas.soderlund@ragnatech.se>\n\t<741abf7a-216c-1ac4-45e6-c51fb0958c90@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<741abf7a-216c-1ac4-45e6-c51fb0958c90@ideasonboard.com>","User-Agent":"Mutt/1.11.4 (2019-03-13)","Subject":"Re: [libcamera-devel] [PATCH] qcam: Allow user to select pixel\n\tformat and resolution","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Mon, 03 Jun 2019 23:24:15 -0000"}}]