Knee Pain and Injury
The pain at the top of the kneecap is classical patellofemoral pain syndrome -- the most common knee problem.  The most direct treatment is simple strengthening exercises for the secondary muscles supporting the knee joint so that the kneecap remains properly positioned -- such exercises can provide relief in 48 hours or less in some cases.  

But you should probably consult a sports medicine doc first.

(My personal experience has been that some sort of toe clip or clipless pedal arrangement helps this condition, vs plain pedals, though there are probably arrangements that can make it worse.)

(And probably the easiest way to make the condition worse is to lower your seat too low and pedal too slowly, in too high a gear.)