From patchwork Wed Nov 5 20:11:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Utkin X-Patchwork-Id: 5237841 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7A6C1C11AC for ; Wed, 5 Nov 2014 20:12:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 94F7820166 for ; Wed, 5 Nov 2014 20:12:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 88FC72015E for ; Wed, 5 Nov 2014 20:12:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751905AbaKEUMk (ORCPT ); Wed, 5 Nov 2014 15:12:40 -0500 Received: from mail-wi0-f178.google.com ([209.85.212.178]:33390 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751269AbaKEUMj (ORCPT ); Wed, 5 Nov 2014 15:12:39 -0500 Received: by mail-wi0-f178.google.com with SMTP id bs8so1138734wib.17 for ; Wed, 05 Nov 2014 12:12:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=0O2WTUuvHrzmKkDr2+VKkLuZZCFofHBhR7wEesrkenw=; b=NYjFNOxCcD0lBwDDeR3iSzlakxVqW9cOvB3A6/1/TCc/mIpXcVoidq6PVoeb7ciwNq kgN6M0yNJ4UfySZ4jmfTRSMCmSjQMQYARZIX6zN4f+VqHh1yJv1YhrvQ/py3RgNFks0L CkVn7lMAu6dZTEhnKIV+MpIQWwPZflOthYxJN7UJj1cv+Rm1N403782DbojDQVHTctSn 5Yo+HWEIcMXhQ6O5aYP+cxKGhIh/+nyBetHQPKTX70lC9SRStFRb53ftpzfkUXsycgOw r1camxGYafBvBz3QG0qHw9CC5IOaSwnztsZIv1QDrZGEe2rzU37H6dee5OTb+86Z8G1R +fsw== X-Gm-Message-State: ALoCoQkPtnBBRYo0i5WqUe+2TgTjzT70nlwmgW/EYeyljSSXU+10+6GVAL72jMOzrgNjyE0/F7eF X-Received: by 10.180.98.170 with SMTP id ej10mr25498748wib.74.1415218358278; Wed, 05 Nov 2014 12:12:38 -0800 (PST) Received: from localhost.localdomain ([149.3.62.89]) by mx.google.com with ESMTPSA id a8sm5687710wiz.21.2014.11.05.12.12.36 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Nov 2014 12:12:37 -0800 (PST) From: Andrey Utkin To: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Cc: m.chehab@samsung.com, hans.verkuil@cisco.com, Andrey Utkin Subject: [PATCH] solo6x10: just pass frame motion flag from hardware, drop additional handling as complicated and unstable Date: Thu, 6 Nov 2014 00:11:14 +0400 Message-Id: <1415218274-28132-1-git-send-email-andrey.utkin@corp.bluecherry.net> X-Mailer: git-send-email 1.8.5.5 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Dropping code (introduced in 316d9e84a72069e04e483de0d5934c1d75f6a44c) which intends to make raising of motion events more "smooth"(?). It made motion event never appear in my installation. That code is complicated, so I couldn't figure out quickly how to fix it, so dropping it seems better to me. Another justification is that anyway application would implement "motion signal stabilization" if required, it is not necessarily kernel driver's job. Signed-off-by: Andrey Utkin Acked-by: Hans Verkuil --- drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c | 30 +------------------------- drivers/media/pci/solo6x10/solo6x10.h | 2 -- 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c index 30e09d9..866f7b3 100644 --- a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c +++ b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c @@ -239,8 +239,6 @@ static int solo_enc_on(struct solo_enc_dev *solo_enc) if (solo_enc->bw_weight > solo_dev->enc_bw_remain) return -EBUSY; solo_enc->sequence = 0; - solo_enc->motion_last_state = false; - solo_enc->frames_since_last_motion = 0; solo_dev->enc_bw_remain -= solo_enc->bw_weight; if (solo_enc->type == SOLO_ENC_TYPE_EXT) @@ -555,36 +553,12 @@ static int solo_enc_fillbuf(struct solo_enc_dev *solo_enc, } if (!ret) { - bool send_event = false; - vb->v4l2_buf.sequence = solo_enc->sequence++; vb->v4l2_buf.timestamp.tv_sec = vop_sec(vh); vb->v4l2_buf.timestamp.tv_usec = vop_usec(vh); /* Check for motion flags */ - if (solo_is_motion_on(solo_enc)) { - /* It takes a few frames for the hardware to detect - * motion. Once it does it clears the motion detection - * register and it takes again a few frames before - * motion is seen. This means in practice that when the - * motion field is 1, it will go back to 0 for the next - * frame. This leads to motion detection event being - * sent all the time, which is not what we want. - * Instead wait a few frames before deciding that the - * motion has halted. After some experimentation it - * turns out that waiting for 5 frames works well. - */ - if (enc_buf->motion == 0 && - solo_enc->motion_last_state && - solo_enc->frames_since_last_motion++ > 5) - send_event = true; - else if (enc_buf->motion) { - solo_enc->frames_since_last_motion = 0; - send_event = !solo_enc->motion_last_state; - } - } - - if (send_event) { + if (solo_is_motion_on(solo_enc) && enc_buf->motion) { struct v4l2_event ev = { .type = V4L2_EVENT_MOTION_DET, .u.motion_det = { @@ -594,8 +568,6 @@ static int solo_enc_fillbuf(struct solo_enc_dev *solo_enc, }, }; - solo_enc->motion_last_state = enc_buf->motion; - solo_enc->frames_since_last_motion = 0; v4l2_event_queue(solo_enc->vfd, &ev); } } diff --git a/drivers/media/pci/solo6x10/solo6x10.h b/drivers/media/pci/solo6x10/solo6x10.h index 72017b7..dc503fd 100644 --- a/drivers/media/pci/solo6x10/solo6x10.h +++ b/drivers/media/pci/solo6x10/solo6x10.h @@ -159,8 +159,6 @@ struct solo_enc_dev { u16 motion_thresh; bool motion_global; bool motion_enabled; - bool motion_last_state; - u8 frames_since_last_motion; u16 width; u16 height;